On Sun, Feb 26, 2012 at 2:58 PM, Ivette <iva_mihaylova at mail.ru>
wrote:> Hello,
>
> Lets suppose I have an Excel sheet with 9 columns of data. How to tell R to
> read for example column 1 and 7 of this sheet? I know only the usual code
> without specifying columns:
>
> library(gdata)
> a <- read.xls("file.xls", sheet=1) ? ? ? ? ? ? ? ?# reads in
the 1st sheet
>
Its pretty much the same as if you were using read.table, viz.
read.xls("file.xls")[c(1, 7])
or if you know that there are nc columns:
nc <- ...
read.xls("file.xls", colClasses = replace(rep("NULL", nc),
c(1, 7), NA))
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com