[R] Error in colnames: target of assignment expands to non-language object

Jinsong Zhao jszhao at yeah.net
Mon Mar 7 08:38:13 CET 2011


Hi there,

I cannot find a detailed explanation to the following error message:

 > colnames(matrix(1:10, ncol = 2)) <- c("X", "Y")
Error in colnames(matrix(1:10, ncol = 2)) <- c("X", "Y") :
   target of assignment expands to non-language object

However, when I do the following things, the error message disappear:

 > z <- matrix(1:10, ncol = 2)
 > colnames(z) <- c("X","y")

What's the difference between the two methods?

Any comments or suggestions? Thank you very much in advance!

Regards,
Jinsong



More information about the R-help mailing list