Skip to content

Unable to read.csv because of special character in file

2 messages · Dennis Fisher, Simon Urbanek

#
Colleagues,

I am trying to read a file that contains the ? (mu character).
readLines is succcessful and shows the following:
	"\xb5g/mL\"

read.csv yields the following:
using a text editor, i replaced all occurrences of ? (mu) - at which  
point read.csv worked properly.

sessionInfo()
Although my work-around was successful, I am wondering whether there  
is some means to accomplish this without editing the source document:
1.  is it possible to inform R to read the character in its natural  
form?
2.  if not, I could execute readLines, then do a gsub (which did not  
work - any ideas of how to formulate the regular expression would be  
appreciated). then write to a tempfile and read in again (or use a  
textConnection).

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220
www.PLessThan.com
#
Please read ?read.csv, most notably about encoding. Apparently your  
file is in Latin1 so have forgotten to specify encoding="latin1".

Cheers,
S
On Jan 20, 2009, at 12:07 , Dennis Fisher wrote: