Hi, Look at ?"["
anadata <- newdata[, cmn] ## i.e., extract all rows (the first argument is empty of the 2 column anadata <- newdata[, 2] Hope this helps, Josh On Tue, Nov 15, 2011 at 8:02 AM, haohao Tsing <haohaor...@gmail.com> wrote: > hi R,users > Now I read a data from a txt file > newdata<-read.table("1.txt") > in the 1.txt ,there are several column shown as below > 1 3 4 5 > 2 3 5 6 > 4 5 6 7 > so when I want analysis the second column > anadata<-newdata$V2 > > but my question I can not use some certain variable to indice the column? > e.g > cmn=2 > anadata<-newdata$Vcmn > > how can I finish this command ?can anyone help me ? thank yo . > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.