Re: [R] Fetching a range of columns

2008-09-15 Thread Jason Thibodeau
David, Using the ?count.fields revealed that I only have 2410 columns. That fixed the problem I had. I used, data_tmp[,842:2410] and that gave me the solution I was looking for. This, ironically, also solved the other problem I had. As for: > > You also say file.remove( fileout) , then you try

Re: [R] Fetching a range of columns

2008-09-14 Thread David Winsemius
On Sep 14, 2008, at 5:39 PM, Adam D. I. Kramer wrote: Hi Jason, data[] is a data frame, remember--you need to specify rows AND columns. So, data[,c(2,12,17)] is what you should be doing in the first place, and data[,842:2411] in the second place. Actually, the construction df[c(2,12,17)]

Re: [R] Fetching a range of columns

2008-09-14 Thread David Winsemius
On Sep 14, 2008, at 4:40 PM, Jason Thibodeau wrote: > I cannot provide (all) the sample data (NDA) but here is the entire > function: > TEST_filter <- function(filein,fileout) > > { > file.remove(fileout) > nskip<-0 > while(1) > { >

Re: [R] Fetching a range of columns

2008-09-14 Thread Adam D. I. Kramer
Hi Jason, data[] is a data frame, remember--you need to specify rows AND columns. So, data[,c(2,12,17)] is what you should be doing in the first place, and data[,842:2411] in the second place. Not sure if the help you needed was using the comma, or the : syntax, or if you're trying to read only

Re: [R] Fetching a range of columns

2008-09-14 Thread David Winsemius
On Sep 14, 2008, at 4:01 PM, Jason Thibodeau wrote: TEST_filter("line50grab.csv","line50grab_filterout.csv") Error in `[.data.frame`(data_tmp, seq(842, 2411)) : undefined columns selected I am guessing that you wrapped some code into a function but you did not provide the function. You ar

Re: [R] Fetching a range of columns

2008-09-14 Thread Jason Thibodeau
TEST_filter("line50grab.csv","line50grab_filterout.csv") Error in `[.data.frame`(data_tmp, seq(842, 2411)) : undefined columns selected I know my file has about 3000 columns. This happened when I used: data_tmp <- read.csv(filein, header=TRUE, nrows=10, skip=nskip) data

Re: [R] Fetching a range of columns

2008-09-14 Thread Jason Thibodeau
Jim, this is a GREAT help. I was trying something similar before, but I was unable to detect EOF. Thanks for the help! Also, David, your suggestion worked perfectly. Thanks for all the help, everyone! On Sun, Sep 14, 2008 at 2:08 PM, jim holtman <[EMAIL PROTECTED]> wrote: > Have you tried: > >

Re: [R] Fetching a range of columns

2008-09-14 Thread jim holtman
Have you tried: data_filter <- data[842:2411] Also if you have a lot of data to read, I would suggest that you use a connection, and it all the data is numeric, possibly 'scan'. If you do use a connection, this would eliminate having to 'skip' each time which could be time consuming on a large f

Re: [R] Fetching a range of columns

2008-09-14 Thread David Winsemius
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 j

[R] Fetching a range of columns

2008-09-14 Thread Jason Thibodeau
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, n