[R] Identifying special characters in a text file

Dennis Fisher fisher at plessthan.com
Fri Feb 12 02:46:07 CET 2010


Colleagues

R 2.10.1 on a Mac

I read in textfiles using readLines, then I process those files, then I use R to execute another program.  Occasionally those files contain characters other than letter / numbers /  routine punctuation marks.  For example, a bullet (option-8 on a Mac) triggers the problem.

Although R can read and process those characters, the other program cannot so I would like to identify these characters and exit gracefully with a warning.

I discovered that the following works:
	any(is.na(strsplit(readLines(FILE), "")))

I am wondering whether anyone has a better approach to this problem.

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com



More information about the R-help mailing list