[R] How to scan df from a specific word?

2010-10-29 Thread M.Ribeiro
Hi R-helpers, I need to read some file with different lines (I don't know the number of lines to skip) and I would like to find a way to start reading the data.frame from the word source. ex: djhsafk asdfhkjash shdfjkash asfhjkash #those lines contain numbers and words, I want to skip

Re: [R] How to scan df from a specific word?

2010-10-29 Thread M.Ribeiro
Sorry, the explanation wasn't very good...just to explain better. I am writing a loop to read and process different files in the same script. And what I want to load into a variable is a data.frame that is above the word source in all of my files. So I would like to recognize the word Source in

Re: [R] How to scan df from a specific word?

2010-10-29 Thread M.Ribeiro
Sorry, the explanation wasn't very good...just to explain better. I am writing a loop to read and process every time a different file in the same script. And what I want to load into a variable each time is a data.frame that is bellow the word source in all of my files. So I would like to

Re: [R] How to scan df from a specific word?

2010-10-29 Thread Phil Spector
It might be easier to preprocess the file before passing it to R, but you an do what you want using a connection: f = file('s.dat','r') while(1){ + txt = readLines(f,1) + if(length(grep('Source',txt)))break; + } while(1){ + more = readLines(f,1) + if(nchar(more) == 0)break; + txt =

Re: [R] How to scan df from a specific word?

2010-10-29 Thread Peter Langfelder
Sorry, this isn't really an R solution, but here it goes anyway. You can isolate the block from Source to the first following blank line by the following unix/linux/cygwin command, assuming inFile is your input file and outFile is the output file: cat inFile | grep -A 100 Source | grep -m 1 -B

Re: [R] How to scan df from a specific word?

2010-10-29 Thread Gabor Grothendieck
On Fri, Oct 29, 2010 at 6:34 PM, M.Ribeiro mresende...@yahoo.com.br wrote: Hi R-helpers, I need to read some file with different lines (I don't know the number of lines to skip) and I would like to find a way to start reading the data.frame from the word source. ex: djhsafk asdfhkjash