[R] Data Import to R

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Sat Nov 15 03:03:36 CET 2014


If your data uses a special marker such as "--" or "n/a" to indicate not available then once you have identified those markers (using any method, though Don's procedure below is what I use) then you can specify them with the na.strings parameter to read.csv. (See the help for read.table for many other parameters you can also give to read.csv.) Once those special values are specified, then you should get numeric columns just fine.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On November 14, 2014 11:11:20 AM PST, "MacQueen, Don" <macqueen1 at llnl.gov> wrote:
>Petr is almost certainly correct. A further suggestion:
>
>Continue to import using stringsAsFactors = FALSE
>
>On one of the columns that should be numeric, use as.numeric(), find
>the
>NA's in the result of that, and then look at those rows of the data.
>There
>will be something there that is non-numeric. By any chance, does your
>data
>use a comma instead of a decimal point (see the "dec" argument to
>read.table)?



More information about the R-help mailing list