[R] Fetching a range of columns

David Winsemius dwinsemius at comcast.net
Tue Sep 16 04:05:04 CEST 2008


On Sep 15, 2008, at 8:15 PM, jim holtman wrote:

> your colClasses should look like this:
>
> colClasses=c(rep("NULL",49), "numeric")
>
> On Mon, Sep 15, 2008 at 6:27 PM, David Winsemius <dwinsemius at comcast.net 
> > wrote:
>>
>>
>>> tstdta <- read.table(file.choose(), colClasses =
>>> append(rep("NULL", 
>>> 48),c("numeric","numeric"),after=45),header=FALSE, skip=1)
>>> tstdta
>> V46 V47
>> 1 177 181
>> 2 178 182
>> 3 179 183
>> 4 180 184

I suppose that works as well. I thought the use of append was  
acceptable as well. If one knew there were 2500
columns, and the desired data were in columns 100-149 then

colClasses = append(rep("NULL",2350), rep("numeric",150), after = 99)

... seems fairly clean.

>
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?



More information about the R-help mailing list