Hi Jack, You need to quote non-syntactic names. A$`A 1` A$'A 1' A$"A 1"
should all work, with the first form being the recommended one. Best, Ista On Wed, Aug 17, 2011 at 1:45 PM, Jack Luo <jluo.rh...@gmail.com> wrote: > Hi, > > After I read an xlsx file into the work space: > A <- read.xlsx("B.xls", header = T, check.names = F) > There are several headers with the names like: > colnames(A) [1:4] > # [1] "A 1" "B" > [3] "C 2" "D" > I can get the content of column 2 and column 4 easily by > A$B or A$D > > However, I can not type something like > A$A 1 (cause there is a space in between) > > Obviously, you can get around this by using something like > A[,colnames(A) == "A 1"] > The other way to get around is to read it by using check.names = T > A <- read.xlsx("B.xls", header = T, check.names = T) > and type something like > A$A.1 > > But I am wondering if I stick using check.names = F, if there is anything > that is as easy as > A$A 1 > that works. > > Thanks, > > -Jack > > [[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. > -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org ______________________________________________ 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.