Hi, I am new to R. I have a matrix that I have assigned to the object ?colon?.> colon<-read.table("c:\\alon.txt",header=T,row.names=1)attach(colon) names(colon) The dimenstions are 2000 62. Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000 different numbers (?continuous? values) within it. I have also assigned a name for each of the 2000 rows of the dataframe with a prefix (i.e. g1 ?. g2000) using the code (not sure if I did this right):> colon<-paste("g",c(1:nrow(colon)),sep="")I have plotted the first 20 values from two of the columns(samples).> x<-c(norm1[1:20])> y<-c(norm2[1:20])> plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 > vs Norm2 - 20genes')> points(x,y,pch=15,col='blue')Now I wish to assign labels to each point (above each point (i.e. pos=3) in the plot with ?g1 to g20 corresponding to each row but I am having trouble with this step. I have tried:> text(x,y, label = row.names(colon[1:20]))but nothing happens. Any suggestions? Thanks in advance MAB -- View this message in context: http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3828461.html Sent from the R help mailing list archive at Nabble.com.
I don't have access to your "alon.txt" file (see ?dput for future posts), but... I'm pretty sure info you want isn't in row.names(colon[1:2]) it should just be text(x,y, label = colon[1:20]) ?? HTH baumeist wrote:> > Hi, > I am new to R. > > I have a matrix that I have assigned to the object ?colon?. > >> colon<-read.table("c:\\alon.txt",header=T,row.names=1) > > attach(colon) > names(colon) > > The dimenstions are 2000 62. > > Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000 > different numbers (?continuous? values) within it. > > I have also assigned a name for each of the 2000 rows of the dataframe > with a prefix (i.e. g1 ?. g2000) using the code (not sure if I did this > right): > >> colon<-paste("g",c(1:nrow(colon)),sep="") > > I have plotted the first 20 values from two of the columns(samples). > >> x<-c(norm1[1:20]) > >> y<-c(norm2[1:20]) > >> plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 >> vs Norm2 - 20 > genes') > >> points(x,y,pch=15,col='blue') > > Now I wish to assign labels to each point (above each point (i.e. pos=3) > in the plot with ?g1 to g20 corresponding to each row but I am having > trouble with this step. > > I have tried: > >> text(x,y, label = row.names(colon[1:20])) > > but nothing happens. > > Any suggestions? > > Thanks in advance > MAB >-- View this message in context: http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3828545.html Sent from the R help mailing list archive at Nabble.com.
A sample data would help. But you could modify as text(x,y, label = row.names(colon[1:20,])) HTH Weidong Gu On Tue, Sep 20, 2011 at 7:43 PM, baumeist <mark.baumeister7 at gmail.com> wrote:> Hi, > I am new to R. > > I have a matrix that I have assigned to the object ?colon?. > >> colon<-read.table("c:\\alon.txt",header=T,row.names=1) > > attach(colon) > names(colon) > > The dimenstions are 2000 ? 62. > > Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000 > different numbers (?continuous? values) within it. > > I have also assigned a name for each of the 2000 rows of the dataframe with > a prefix (i.e. g1 ?. g2000) using the code (not sure if I did this right): > >> colon<-paste("g",c(1:nrow(colon)),sep="") > > I have plotted the first 20 values from two of the columns(samples). > >> x<-c(norm1[1:20]) > >> y<-c(norm2[1:20]) > >> plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 >> vs Norm2 - 20 > genes') > >> points(x,y,pch=15,col='blue') > > Now I wish to assign labels to each point (above each point (i.e. pos=3) in > the plot with ?g1 to g20 corresponding to each row but I am having trouble > with this step. > > I have tried: > >> text(x,y, label = row.names(colon[1:20])) > > but nothing happens. > > Any suggestions? > > Thanks in advance > MAB > > > -- > View this message in context: http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3828461.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. >
#This should work (again, without your data ??) colon<-read.table("c:\\alon.txt",header=T,row.names=1) row.names(colon) <-paste("g",c(1:nrow(colon)),sep="") with(colon[1:20,], plot(norm1, norm2, type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 vs Norm2 - 20 genes')) with(colon, text(norm1, norm2, label = row.names(colon[1:20,])) baumeist wrote:> > Hi, > I am new to R. > > I have a matrix that I have assigned to the object ?colon?. > >> colon<-read.table("c:\\alon.txt",header=T,row.names=1) > > attach(colon) > names(colon) > > The dimenstions are 2000 62. > > Each of the 62 columns (titled norm1, norm2, norm3, etc) has 2000 > different numbers (?continuous? values) within it. > > I have also assigned a name for each of the 2000 rows of the dataframe > with a prefix (i.e. g1 ?. g2000) using the code (not sure if I did this > right): > >> colon<-paste("g",c(1:nrow(colon)),sep="") > > I have plotted the first 20 values from two of the columns(samples). > >> x<-c(norm1[1:20]) > >> y<-c(norm2[1:20]) > >> plot(x,y,type='n',xlab='x norm1 sample',ylab='y norm2 sample',main='Norm1 >> vs Norm2 - 20 > genes') > >> points(x,y,pch=15,col='blue') > > Now I wish to assign labels to each point (above each point (i.e. pos=3) > in the plot with ?g1 to g20 corresponding to each row but I am having > trouble with this step. > > I have tried: > >> text(x,y, label = row.names(colon[1:20])) > > but nothing happens. > > Any suggestions? > > Thanks in advance > MAB >-- View this message in context: http://r.789695.n4.nabble.com/adding-labels-to-x-y-points-tp3828461p3830363.html Sent from the R help mailing list archive at Nabble.com.