On Sat, Sep 10, 2016 at 07:23:37PM +0000, Glenn Schultz wrote:
> ...
> Below is the function that I am writing.  I am using sed to replace the hex 
> characters.  First, to get past NUL I use sed to replace hex 00 with hex 20.  
> This has worked.  Once the Nul is removed and can successfully parse the file 
> with ReadLine sub_str.  This final step before delimiting the file and making 
> it nice and tidy is to remove the hex 20 characters.   I am using the same 
> strategy to eliminate the spaces and sed command works in a shell but does 
> not work in the R function.  What am I doing wrong?  I have dput - some of 
> the nastier lines with hex 20 characters below my code.

I believe that you will find that the sed "d" command deletes the
"pattern space" (in a simple text file, it would delete the line) in
which the specified regular expression is found.

I suspect that you actually want to eliminate the "space" characters
themselves, so rather than:

> ...
> # The file has been parsed accroding to length 400 for each data element.
> # The next step is to remove all the trailing white space hex character
> # x20
> 
> sedcommand2 <- paste("sed -e '/\\x20/d' <", 

what is wanted is:

sedcommand2 <- paste("sed -e 's/\\x20//g' <", 

> ... 

Note that you might consider using R's gsub() function to perform that
"space elimination"both natively and a bit earlier.

Peace,
david
-- 
David H. Wolfskill                              r...@catwhisker.org
Those who would murder in the name of God or prophet are blasphemous cowards.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.

Attachment: signature.asc
Description: PGP signature

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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