Dennis,

You can get rid of the '^M' by reformating the 
file from DOS to UNIX. Withing a UNIX system 
send the command
   > dos2unix filename1 filename2.
Filename2 won't have the '^M'.

Hope it helps,

Augusto


--------------------------------------------
Augusto Sanabria. MSc, PhD.
Mathematical Modeller
Risk Research Group
Geospatial & Earth Monitoring Division
Geoscience Australia (www.ga.gov.au)
Cnr. Jerrabomberra Av. & Hindmarsh Dr.
Symonston ACT 2601
Ph. (02) 6249-9155
 
 




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dennis Fisher
Sent: Tuesday, 14 November 2006 9:06
To: [email protected]
Subject: [R] Embedded carriage returns in text document


Colleagues,

I am using R 2.4.0 on both a Mac (10.4.8) and Linux (RedHat 9).  To  
read data from an Excel spreadsheet, I do "save as"  in Excel, then  
select the "Text (tab-delimited)" format.  The resulting file uses a  
tab separator and I can usually read the file using read.delim.

Sometimes, the header row contains embedded carriage returns.  When I  
view the file, these carriage returns appear as  "^M".

Now the problem:
When I read.delim these files, they do not read correctly.  Sometimes  
I get error messages; sometimes only the first line is read.   
Interestingly, invoking the option skip=1 (or a larger N) does not  
appear to bypass the problem.

I can solve the problem by manually deleting these carriage returns  
either in the original Excel file or the .txt version.   However,  
this is not an ideal solution.

Does anyone have a work-around within R?

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       


        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

______________________________________________
[email protected] 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.

Reply via email to