Hi, Fairly new to R - have done basic plots but now faced with plotting a matrix/table of results -I know what I want but cannot find out how to do it. Basically have individual questions ( x) to which an organization can rate themselves 1-10 (y) what I want to show is a matrix/density type plot (like the matrix corrolation plots I have seen on R graph site) showing for eac question (x) a circle or shape of varying size and/or colour to represent the number of organisations rating themselves for each value of y. Hope this makes sense, any advice would be gratefully received. HH
Hi:
Are you thinking of a levelplot/heatmap? Some places to look:
?levelplot in the lattice package
?geom_tile in the ggplot2 package
?heatmap2 in the gplots package
You can find many more heatmap functions in R; try
library(sos) # install first if you don't have it - *very* handy
for quick searches
findFn('heatmap')
There are more than a few packages with heatmap functions...
HTH,
Dennis
On Wed, Sep 29, 2010 at 3:55 AM, hairryharry <hairryharry@tesco.net>
wrote:
> Hi,
>
> Fairly new to R - have done basic plots but now faced with plotting a
> matrix/table of results -I know what I want but cannot find out how to do
> it.
>
> Basically have individual questions ( x) to which an organization can rate
> themselves 1-10 (y) what I want to show is a matrix/density type plot (like
> the matrix corrolation plots I have seen on R graph site) showing for eac
> question (x) a circle or shape of varying size and/or colour to represent
> the number of organisations rating themselves for each value of y.
>
> Hope this makes sense, any advice would be gratefully received.
>
> HH
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
On 09/29/2010 08:55 PM, hairryharry wrote:> Hi, > > Fairly new to R - have done basic plots but now faced with plotting a > matrix/table of results -I know what I want but cannot find out how to > do it. > > Basically have individual questions ( x) to which an organization can > rate themselves 1-10 (y) what I want to show is a matrix/density type > plot (like the matrix corrolation plots I have seen on R graph site) > showing for eac question (x) a circle or shape of varying size and/or > colour to represent the number of organisations rating themselves for > each value of y. > > Hope this makes sense, any advice would be gratefully received. >Hi Harry, The balloonplot function will probably give you the circles you want. If you want a matrix of colors, color2D.matplot might help, and if you just want a display of counts, try count.overplot. Jim
HH-
I'm not familiar with the plots you mention, but the following is a quick
attempt to create the plot you describe.
data<-data.frame(
org=1:10,
q1=sample(1:10,replace=T),
q2=sample(1:10,replace=T),
q3=sample(1:10,replace=T))
# This generates a random data set like the one you describe. It looks
like this:
# org q1 q2 q3
#1 1 9 1 4
#2 2 1 2 1
#3 3 1 3 7
#4 4 10 9 6
# ...
n<-ncol(data)-1 # NUMBER OF ORGANIZATIONS
new.mat<-apply(data[,-1],2,function(x){xtabs(~factor(x,levels=1:10))})
plot(rep(1:n,each=10),rep(1:10,n),
pch=16,
cex=c(new.mat),
xaxt="n",
xlab="Question",
ylab="Score")
axis(1,at=1:n)
Instead of cex=c(new.mat), you can supply a function of new.mat, say
cex=f(new.mat) to specify the size of the dots.
Hope that helps.
-tgs
On Wed, Sep 29, 2010 at 6:55 AM, hairryharry <hairryharry@tesco.net>
wrote:
> Hi,
>
> Fairly new to R - have done basic plots but now faced with plotting a
> matrix/table of results -I know what I want but cannot find out how to do
> it.
>
> Basically have individual questions ( x) to which an organization can rate
> themselves 1-10 (y) what I want to show is a matrix/density type plot (like
> the matrix corrolation plots I have seen on R graph site) showing for eac
> question (x) a circle or shape of varying size and/or colour to represent
> the number of organisations rating themselves for each value of y.
>
> Hope this makes sense, any advice would be gratefully received.
>
> HH
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
On Wed, Sep 29, 2010 at 6:55 AM, hairryharry <hairryharry at tesco.net> wrote:> Hi, > > Fairly new to R - have done basic plots but now faced with plotting a > matrix/table of results -I know what I want but cannot find out how to do > it. > > Basically have individual questions ( x) to which an organization can rate > themselves 1-10 (y) what I want to show is a matrix/density type plot (like > the matrix corrolation plots I have seen on R graph site) showing for eac > question (x) a circle or shape of varying size and/or colour to represent > the number of organisations rating themselves for each value of y. > > Hope this makes sense, any advice would be gratefully received. >Check out balloonplot in the gplots package. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com