[R] matrix plot

hairryharry hairryharry at tesco.net
Wed Sep 29 20:48:20 CEST 2010


Thanks,

Thats great just what I was trying to do.

HH


Thomas Stewart wrote:
> 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 at tesco.net 
> <mailto: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.
>
>     HH
>
>     ______________________________________________
>     R-help at r-project.org <mailto:R-help at 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.
>
>



More information about the R-help mailing list