On 7/20/2005 9:54 AM, [EMAIL PROTECTED] 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

Reply via email to