[R] using read.table, removing extra quotation mark from a text field? (e.g. ""cat" )
jim holtman
jholtman at gmail.com
Sun Sep 12 21:58:45 CEST 2010
You can use the 'gsub' command to remove the quote marks. You could
readLines/writeLines the file to clean it up with gsub before using
read.table on it so it can all be done within R.
On Sun, Sep 12, 2010 at 1:58 PM, Eva Nordstrom <eva.nordstrom at yahoo.com> wrote:
> I am using read.table to import a text file within R.
>
> There are several "errors" in my text file. An "extra" quotation mark has
> inadvertently been included within a few text fields.
>
>
> e.g. for a pipe (|) delimited text file, I have something similar to this:
>
> 1|7|30| "dog"
> 2|6|25| ""cat"
> 3|4|20|""
> 4|5| 56| "mouse"
> 5|3|56| ""horse"
> 6|56| ""
>
> In the above example| there are extra quotation marks within the fields for cat
> and horse. (row 2 and row 5)
>
> e.g. "cat , "horse
>
> One solution is to simply edit the text file and remove the extra quotation
> mark.
>
> Is there a "good solution" I can implement form within R?
>
> I am OK with just importing the extra quotation marks and having nit show up as
> part of the text field within R.
>
> e.g,
> "cat
> "horse
>
> Thanks.
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list