[R] Fetching a range of columns
David Winsemius
dwinsemius at comcast.net
Sun Sep 14 19:59:22 CEST 2008
On Sep 14, 2008, at 12:22 PM, Jason Thibodeau wrote:
> Hello,
>
> I realize that using: x[x > 3 & x < 5] I can fetch all elements
> between 3
> and 5. However I read in from a CSV file, and I would like to fetch
> all
> columns from within a range ( 842-2411). In teh past, I have done
> this to
> fetch just select few columns:
>
> data <- read.csv(filein, header=TRUE, nrows=320, skip=nskip)
> data_filter <- data[c(2,12,17)]
> write.table(data_filter, fileout, append =
> TRUE,
> sep= ",", row.names= FALSE, col.names = FALSE)
> nskip <- nskip+320
>
> This time, however, instead of grabbing columns 2, 12, 17, I woudl
> like all
> columns in the range of 842-2411. I can't seem to do this correctly.
> Could
> somebody please provide some insight? Thanks in advance.
Have your tried:
data_filter <- data[seq(842,2411)]
write.table(data_filter, fileout, append = TRUE, sep= ",", row.names=
FALSE, col.names = FALSE)
When I use that format on a dataframe I have lying around, I get the
expected results and I do not find in testing that dataframes are
challenged by assigning 5000 columns.
--
David Winsemius
More information about the R-help
mailing list