If i is 1:20, there are no column names. Make sure you are indexing the names from your your dataframe.
> xx <- data.frame(a=c(1:10), b = letters[1:10]) > colnames(xx) [1] "a" "b" > for(i in 1:2) print(colnames(xx)[i]) [1] "a" [1] "b" > for(i in colnames(xx)) print(i) [1] "a" [1] "b" Matt Austin Statistician Amgen One Amgen Center Drive M/S 24-2-C Thousand Oaks CA 93021 (805) 447 - 7431 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Laura Quinn > Sent: Wednesday, February 16, 2005 6:47 AM > To: Uwe Ligges > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Passing colnames to graphics title > > > Obviously I have been trying to use the colnames() function! > > However, when I try to subscript ie: > > for(i in 1:20){ > main=paste("Site:",colnames(i),sep="") > } > > this doesn't work! I thought that as.character(colnames(i)) or > substitute(colnames(i)) might work, but to no avail... > > Laura Quinn > Institute of Atmospheric Science > School of Earth and Environment > University of Leeds > Leeds > LS2 9JT > > tel: +44 113 343 1596 > fax: +44 113 343 6716 > mail: [EMAIL PROTECTED] > > On Wed, 16 Feb 2005, Uwe Ligges wrote: > > > Laura Quinn wrote: > > > > > Hi, > > > > > > Just a quick query - if I'm creating a function to > produce a number of > > > histograms per page of output (one per column from a > matrix), how can I > > > pass the column name of the matrix into the title (or > indeed to form part > > > of the x-axis label)? > > > > > > By extracting them using colnames()? > > > > Uwe Ligges > > > > > > > > > TIA, > > > Laura > > > > > > Laura Quinn > > > Institute of Atmospheric Science > > > School of Earth and Environment > > > University of Leeds > > > Leeds > > > LS2 9JT > > > > > > tel: +44 113 343 1596 > > > fax: +44 113 343 6716 > > > mail: [EMAIL PROTECTED] > > > > > > ______________________________________________ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html