Re: [R] rotate column names in large matrix

2010-11-16 Thread Lara Poplarski
Thank you both, these are very helpful hints.

Chris, could you please suggest how to modify what you sent to also show the
same labels as (horizontal) row names? I have not yet mastered the details
of R graphics...

Many thanks in advance,
Lara

On Mon, Nov 15, 2010 at 3:25 PM, Chris Stubben stub...@lanl.gov wrote:


 You could display the matrix as an image then add column names (rotated
 used
 srt) if you really want them.

 x - cor(matrix(rnorm(600), 60, 100))

 # set margins with extra space at top and xpd=TRUE to write outside plot
 region
 op-par(mar=c(1,1,5,1), xpd=TRUE)

 # display image without the 90 degree counter clockwise rotation
 image(t(x[nrow(x):1,]), axes=FALSE)

 ## add 100 column names
 y-paste(column, 1:100)
 text( seq(0,1,length=100) , 1.01, y,  pos = 2, srt = 270, offset=0, cex=.7)


 Chris Stubben





 Lara Poplarski wrote:
 
  I have a large (1600*1600) matrix generated with symnum, that I am using
  to
  eyeball the structure of a dataset.
 
  I have abbreviated the column names with the abbr.colnames option. One
 way
  to get an even more compact view of the matrix would be to display the
  column names rotated by 90 degrees.
 
  Any pointers on how to do this would be most useful. Any other tips for
  displaying the matrix in compact form are of course also welcome.
 
 
 

 --
 View this message in context:
 http://r.789695.n4.nabble.com/rotate-column-names-in-large-matrix-tp3043493p3043927.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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]]

__
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.


Re: [R] rotate column names in large matrix

2010-11-16 Thread Chris Stubben

Just increase the margins on the left side and add the rownames

x - cor(matrix(rnorm(600), 60, 100))
rownames(x)-paste(row, 1:100)
op-par(mar=c(1,5,1,1), xpd=TRUE)
image(t(x[nrow(x):1,]), axes=FALSE)
 text(-0.01, seq(0,1,length=nrow(x) ), rownames(x), pos = 2,  offset = 0,
cex = .7)

Another option is to search the R graphics manual at
http://rgm2.lab.nig.ac.jp/RGM2/images.php and maybe you'll find a function
in all those packages that plots what you need.   Try searching for symnum
or image key or matrix plot (in quotes).  For matrix plot, there's a
function in the plotrix package that will add a key or even show values in
the cells..

library(plotrix)
color2D.matplot(x, show.legend=TRUE, red=1, blue=0)

Chris




Lara Poplarski wrote:
 
 Chris, could you please suggest how to modify what you sent to also show
 the
 same labels as (horizontal) row names? I have not yet mastered the details
 of R graphics...
 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/rotate-column-names-in-large-matrix-tp3043493p3045366.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] rotate column names in large matrix

2010-11-15 Thread Joshua Wiley
Hi Lara,

Hmm, I've never seen column names rotated in R (certainly you could in
graphics, etc. and this should do it in that case:
lapply(strsplit(colnames(x), ''), paste, collapse = \n)  ).  You
could transpose the matrix so the columns become the rows and then
just have numbers (1:1600) as the columns?  That's the best solution
I've found when dealing with large correlation matrices.  I also
usually set options(digits = 2) or thereabouts (or use round() ).  I'd
be interested in seeing any other ideas people have also as this has
been troublesome to me in the paste some too.  As much as I hate to
say it, I find it easier to view some of these things in Excel (you
can just write the matrix to the clipboard and paste into Excel or
probably open office (though I have not tried)) because it has easy
scrolls bars and zooming.

Cheers,

Josh

On Mon, Nov 15, 2010 at 9:47 AM, Lara Poplarski larapoplar...@gmail.com wrote:
 Dear List,


 I have a large (1600*1600) matrix generated with symnum, that I am using to
 eyeball the structure of a dataset.


 I have abbreviated the column names with the abbr.colnames option. One way
 to get an even more compact view of the matrix would be to display the
 column names rotated by 90 degrees.


 Any pointers on how to do this would be most useful. Any other tips for
 displaying the matrix in compact form are of course also welcome.


 Many thanks,

 Lara

        [[alternative HTML version deleted]]

 __
 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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

__
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.


Re: [R] rotate column names in large matrix

2010-11-15 Thread Chris Stubben

You could display the matrix as an image then add column names (rotated used
srt) if you really want them. 

x - cor(matrix(rnorm(600), 60, 100))  

# set margins with extra space at top and xpd=TRUE to write outside plot
region
op-par(mar=c(1,1,5,1), xpd=TRUE)

# display image without the 90 degree counter clockwise rotation
image(t(x[nrow(x):1,]), axes=FALSE)

## add 100 column names
y-paste(column, 1:100)
text( seq(0,1,length=100) , 1.01, y,  pos = 2, srt = 270, offset=0, cex=.7)


Chris Stubben





Lara Poplarski wrote:
 
 I have a large (1600*1600) matrix generated with symnum, that I am using
 to
 eyeball the structure of a dataset.
 
 I have abbreviated the column names with the abbr.colnames option. One way
 to get an even more compact view of the matrix would be to display the
 column names rotated by 90 degrees.
 
 Any pointers on how to do this would be most useful. Any other tips for
 displaying the matrix in compact form are of course also welcome.
 
 
 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/rotate-column-names-in-large-matrix-tp3043493p3043927.html
Sent from the R help mailing list archive at Nabble.com.

__
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.