Re: [R] Prefix for colnames

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Thu 21 Jul 2005 - 00:03:20 EST

On 7/20/2005 9:54 AM, jhainm@fas.harvard.edu wrote:
> Hi,
>
> I would like to add a prefix to colnames in a matrix but I can't get the prefix
> option in colnames to work. What am I doing wrong?

The prefix argument is only used when there are no names and colnames is generating some. You just want to use paste().

>

>> X<-matrix(NA,3,4)
>> colnames(X)<-c("test","test","test","test")

 > colnames(X) <- paste("PREFIX.", colnames(X), sep="")  > X

      PREFIX.test PREFIX.test PREFIX.test PREFIX.test
[1,]          NA          NA          NA          NA
[2,]          NA          NA          NA          NA
[3,]          NA          NA          NA          NA

Duncan Murdoch



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 Received on Thu Jul 21 00:11:06 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:51 EST