[R] using a regular expression
marco.prado.bs at gmail.com
Sun Sep 11 17:54:11 CEST 2016
Excerpts from Glenn Schultz's message of 2016-09-10 19:23:37 +0000:
> I have a file that for basically carries three datasets of differing
> lengths. To make this a single downloadable file the creator of the
> file as used both NUL hex00 and space hex20 to normalize the lengths.
> 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.
> Any advice is appreciated.
You can use readLines(pipe(sedcommand)) to get the filtered dataset.
I didn't understand what kind of filtering you are doing, it seems
confused to me. But, someone pointed out that use of command 'd' is for
deletion of the role pattern space, so if you are trying to substitute
s/pattern//g # effectively removing pattern from the text
Marco Arthur @ (M)arco Creatives
More information about the R-help