[R] eliminating control characters from formatted data files
myrmail at earthlink.net
Thu Feb 5 15:13:25 CET 2009
This may be a case of "If all you have is a hammer, everything looks like a
If all you want to do is remove the last line if it contains a CONTROL-Z,
not use something like perl to process the files?
Murray M Cooper, Ph.D.
9800 N 24th St
Richland, MI, USA 49083
Mail: richstat at earthlink.net
----- Original Message -----
From: "David Epstein" <David.Epstein at warwick.ac.uk>
To: <r-help at r-project.org>
Sent: Thursday, February 05, 2009 4:01 AM
Subject: [R] eliminating control characters from formatted data files
> I have a few hundred files of formatted data. Unfortunately most of them
> with a spurious CONTROL-Z. I want to rewrite the files without the
> character. Here's what I've come up with so far, but my code is unsafe
> because it assumes without justification that the last row of df contains
> control character (and some NAs to fill up the record).
> options(warn=-1) #turn off irritating warning from read.table()
> write.table(df.new,file=filename.new, quote=F)
> Before defining df.new, I want to check that the last line really does
> contain a control character. I've tried various methods, but none of them
> I have been wondering if I should use a function (scan?) that reads in the
> file line by line and checks each line for control characters, but I don't
> know how to do this either.
> Thanks for any help
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help