[R] Problems getting symbols() to show table data

Gabor Grothendieck ggrothendieck at gmail.com
Fri Apr 16 04:58:31 CEST 2010


Try this:

library(gplots)
URL <- "http://n4.nabble.com/file/n1890724/test-data.txt"
DF <- read.table(URL)

balloonplot(colnames(DF)[col(DF)], rownames(DF)[row(DF)],
	abs(as.matrix(DF)),
	dotcolor = c("lightblue", "red")[(c(matrix_data) < 0) + 1],
	show.margins = FALSE, cum.margins = FALSE,
	xlab = "", ylab = "", label = TRUE, label.lines = FALSE,
	colsrt = 90, sorted = FALSE, rowmar = 3, colmar = 2.5)



On Thu, Apr 15, 2010 at 9:23 AM, Guy Green <guygreen at netvigator.com> wrote:
>
> Thanks, balloonplot() is great and gets me really close to what I am after.
>
> However it then brings me to a slightly different problem - I wonder if
> anyone can suggest where I am going wrong?
>
> Again with simplified data (
> http://n4.nabble.com/file/n1890724/test-data.txt test-data.txt ):
>
>           Aug-03   Nov-03   Feb-04   May-04   Aug-04
> Row1       1         -1.1         1.2        1.3        -1.4
> Row2       3         -3.1         3.2        3.3        -3.4
> Row3       5         -5.1         5.2       -5.3         5.4
>
> library(gplots)
> Read_data=read.table("C:/files/test-data.txt", head = T)
> number_rows = nrow(Read_data)
> number_cols = ncol(Read_data)
> matrix_data = as.matrix(Read_data)
> row_names = rep(rownames(matrix_data),number_cols)
> col_names = rep(colnames(matrix_data),number_rows)
> x11(width=120, height=80)
> balloonplot(col_names, row_names, abs(matrix_data),
>        dotcolor = c("lightblue", "red")[(c(matrix_data) < 0) + 1],
>        show.margins = FALSE, cum.margins = FALSE,
>        xlab = "", ylab = "", label=T, label.lines= F, colsrt=90, sorted = F,
>        rowmar=3, colmar=2.5,)
>
> This gives this graphic:  http://n4.nabble.com/file/n1890724/R_upload.jpeg
> R_upload.jpeg .
>
> The data colours go in the "right" places within the grid - i.e. with the
> correct numbers.  However the numbers themselves are mixed up within each
> row.  Transposing the matrix_data within balloonplot() doesn't correct it.
>
> Can someone see something simple that I am missing here?  Thanks,
>
> Guy
> --
> View this message in context: http://n4.nabble.com/Problems-getting-symbols-to-show-table-data-tp1839676p1890724.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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