You can use readLines to read the data in and then gsub to remove the
characters you don't want and the textConnection to 'read' in the processed
data.

> x <- readLines("/tempxx.txt")
> # show data
> x
[1] "al;skdjf a;lskdjf s;aldkfj asd;lfkj "   "_)(*)(*&*(&^
&*(^%*&^%"
[3] "a;lskdfj z,xmcvn -129037854 b qwepoiru"
"1234l;kjasdfmnb5"
> # now delete all numbers using regular expression (substitute your
characters)
> # you can put any characters you want separated by '|'
> x.d <- gsub("0|1|2|3|4|5|6|7|8|9", '', x)
> # reread using textConnection
> x.new <- readLines(textConnection(x.d))
> x.new
[1] "al;skdjf a;lskdjf s;aldkfj asd;lfkj " "_)(*)(*&*(&^
&*(^%*&^%"
[3] "a;lskdfj z,xmcvn - b qwepoiru"
"l;kjasdfmnb"
>


On Tue, May 26, 2009 at 7:12 PM, Daniel Bradley <dannyboy...@gmail.com>wrote:

> Hi!
>
> I'm completely confusing myself attempting to solve this one.  Is there a
> simple way of removing particular ASCII characters from a CSV file using R.
> Hopefully something simpler and faster than cycling through each individual
> character and comparing them to a list of characters to remove then
> deleting
> as necessary.
>
> As always, any help would be appreciated.
>
> Thanks!
> Dan
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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