Thanks for your suggestions. Bert, in your response you raised my awareness to "regular expressions". Are regular expressions the same across various languages? Consider the following line of text:
txt_line<-" PERCENT DISCREPANCY = 0.01 PERCENT DISCREPANCY = -0.05" It seems python uses the following line of code to extract the two values in "txt_line" and store them in a variable called "v": v = re.findall("[+-]? *(?:\d+(?:\.\d*)|\.\d+)(?:[eE][+-]?\d+)?", line) #v[0] 0.01 #v[1] -0.05 I tried something similar in R (but it didn't work) by using the same regular expression, but got an error: edm<-grep("[+-]? *(?:\d+(?:\.\d*)|\.\d+)(?:[eE][+-]?\d+)?",txt_line) #Error: '\d' is an unrecognized escape in character string starting "[+-]? *(?:\d" I'm not even sure which function in R most efficiently extracts the values from "txt_line". Basically, I want to peel out the values and think I can use the decimal point to construct the regular expression, but don't know where to go from here? -- View this message in context: http://r.789695.n4.nabble.com/extracting-values-from-txt-file-that-follow-user-supplied-quote-tp4632558p4632724.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.