a question of Data quotation
Zongshan,
When you use cbind, R will combine them as a matrix and unfortunately
the $ way of indexing columns does not work for matrices. A better way
to get what you want would be like this:
data<-data.frame(jan=npp$JAN,feb=npp$FEB)
Hope this helps,
Chris
Zongshan, Li wrote:
Dear the friends of R-Ecology:
I am a beginner for R language, therefore I am sure that this question is possibly quite simple, but it still mean a big problem to me.
I select two columns of 'npp' to combine a new variable:data, and give its colnames as jan and feb, the code is following:
data<-cbind(npp$JAN,npp$FEB)
colnames(data)<-c("jan","feb")
I found that the columns of 'data',could not quoted as 'data$jan',or'data$feb',but can quoted well as data[,1] or data[,2].
Tips of R-software is 'data$jan : $ operator is invalid for atomic vectors'
I try to use the function 'as.matrix' convert the data to numeric type,but get the just same result. I am confused about this problem.
Any help is strongly appreciated,
thank you in advance,
Zongshan, Li??zsli_st at rcees.ac.cn
2009-12-01
Research Center for Eco-Environmental Sciences,Chinese Academy of Sciences
Shuangqing Road, Haidian street, Beijing, 100085
Tel: 86-10-13699145748
QQ: 1141958023
email: zsli_st at rcees.ac.cn
website: http://www.rcees.ac.cn/
[[alternative HTML version deleted]]
------------------------------------------------------------------------
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology