extracting information from txt file
This worked fine for me:
x <- read.csv("http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt", skip=84, as.is = TRUE)
str(x)
'data.frame': 711 obs. of 75 variables: $ ALDI : chr "." "." "." "." ... $ ALDS : chr "." "S" "S" "S" ... $ ALDSF : chr " " " " " " " " ... $ ALKCALC : chr "106.05" "210.7" "73.51" "432.63" ... $ ALOR : chr "." "S" "S" "S" ... $ ALORF : chr " " " " " " " " ... $ ALTD : chr "54" "36" "47" "12" ... $ ALTDF : chr " " " " " " " " ... $ ANC : chr "115" "207.2" "82.2" "435.2" ...
On Wed, Oct 31, 2012 at 12:46 PM, chuck.01 <CharlieTheBrown77 at gmail.com> wrote:
Hello, Here is a link to some data: http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt I am trying to read this in, and want to use: chmval <- read.table("http://www.epa.gov/emap/html/data/surfwatr/data/mastreams/9396/wchem/chmval.txt", sep=",", skip= 84, header=T) the # 84, for 84 lines skipped needs to be derived from the 5th line of the txt file # Header Records: 85 so, I need that # (-1) for input into the read.table statement above I've tried grep but that didn't work: (for this I downloaded the txt file and manually removed that hash mark!) grep("Header Records:", read.table("chmval.txt", header=T)) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 5 elements Any ideas? Can I just extract the 5th line? -- View this message in context: http://r.789695.n4.nabble.com/extracting-information-from-txt-file-tp4648033.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.