You could also do:

data <- cbind(1:10, 1:10)
colnames(data) <- c("a","b")
data <- as.data.frame(data)
then data$a works fine

all the best J
On Tue, Dec 1, 2009 at 3:20 AM, Zongshan, Li <zsli_st@rcees.ac.cn> 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@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@rcees.ac.cn
> website: http://www.rcees.ac.cn/
>
>        [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>

	[[alternative HTML version deleted]]

