Re: [R] na.strings in readLines or is.na?

From: John Fox <jfox_at_mcmaster.ca>
Date: Wed 02 Mar 2005 - 09:14:15 EST


Dear Ben,

Since readLines() returns the lines in the file as character strings, it wouldn't be appropriate for it to substitute for missing values on input. One approach would be to replace "-99.99" with "NA" in the strings, but a simpler method would be to deal with the data frame (say DF):
  DF[DF == -99.99] <- NA
(assuming that you've converted the strings to numeric values).

I hope this helps,
 John

On Tue, 1 Mar 2005 13:43:23 -0500
 "Benjamin M. Osborne" <Benjamin.Osborne@uvm.edu> wrote:
> When reading a data set into R using readLines, na.strings="-99.99"
> is ignored.
> Is there an equivalent command for readLines? Alternatively, either
> immediately after reading into R or once the data set has been
> converted to a
> data frame, what is the appropriate command (or appropriate use of
> is.na) to
> convert my -99.99s to NAs?
> Thanks,
> Ben Osborne
>
> --
> Botany Department
> University of Vermont
> 109 Carrigan Drive
> Burlington, VT 05405
>
> benjamin.osborne@uvm.edu
> phone: 802-656-0297
> fax: 802-656-0440
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Mar 02 09:22:35 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:39 EST