Convert a full length column to one variable in a row in R -
i wondering if possible convert 1 column 1 variable next eachother
i.e.:
d <- data.frame(y = 1:10) > d y 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
convert column into:
> d 1 2 3 4 5 6 7 8 9 10
we don't know how going use numbers, think unnecessary make transformation. can use d$y
numbers applied map of colors. see example.
d <- data.frame(y = 1:7) library(rcolorbrewer) mypalette<-brewer.pal(4,"greens") mycol <-palette()#rainbow(7) heatmap(matrix(1:28,ncol=4),col=mypalette[d$y[1:4]],xlab="greens (sequential)", ylab="",xaxt="n",yaxt="n",bty="n",rowsidecolors=mycol[d$y])
Comments
Post a Comment