[R] eliminating control characters from formatted data files

David Epstein David.Epstein at warwick.ac.uk
Thu Feb 5 10:01:54 CET 2009

I have a few hundred files of formatted data. Unfortunately most of them end
with a spurious CONTROL-Z. I want to rewrite the files without the spurious
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 a
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: http://www.nabble.com/eliminating-control-characters-from-formatted-data-files-tp21847583p21847583.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list