[R] recognizing "(" as a character
ligges at statistik.uni-dortmund.de
Sat Nov 15 15:34:14 CET 2003
Jean Eid wrote:
> Dear All,
> I have been trying to scan data from pdf files and use R to seperate them.
> The following will make it clear
> I have a line that reads
> "Intrepid (D) 15,977 11,956 45,143 39,014"
> where what is in the parenthesis is either a "D" for domestic or "I" for
> I want to try to strsplit the line according to the full character "(D)"
> or "(I)" but unfortunately R recognizes this as "D", or "I" in the
> strsplit command. my question is is there any way that I can tell R that
> this "(" is a character.
> P.S. even grep() does have the same problem. I know this is not a problem
> since "(", ")", "[", etc.. are predefined in R but why is the quotation
> marks for strings not doing its job here?
> Jean Eid
These functions do use regular expression. Try e.g.:
strsplit("Intrepid (D) 15,977 11,956 45,143 39,014", "\\(D\\)")
More information about the R-help