Hello, I have a CSV file with region codes listed in a column. E.g. 'AS' for Asia, 'AU' for Australia and 'NA' North America. However, the data frame created using read.csv shows <NA> where the string variable should have had the value 'NA'. How can I input the value 'NA' present in a column in a CSV file without R changing it to missing? Thanks Nikhil [[alternative HTML version deleted]]
I believe read.csv(..., na.strings = "") will do it. Michael On Mon, Feb 27, 2012 at 8:15 AM, nikhil abhyankar <nsabhyankar at gmail.com> wrote:> Hello, > > I have a CSV file with region codes listed in a column. E.g. 'AS' for Asia, > 'AU' for Australia and 'NA' North America. > > However, the data frame created using read.csv shows <NA> where the string > variable should have had the value 'NA'. > > How can I input the value 'NA' present in a column in a CSV file without R > changing it to missing? > > Thanks > > Nikhil > > ? ? ? ?[[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.
On Feb 27, 2012, at 14:15 , nikhil abhyankar wrote:> Hello, > > I have a CSV file with region codes listed in a column. E.g. 'AS' for Asia, > 'AU' for Australia and 'NA' North America. > > However, the data frame created using read.csv shows <NA> where the string > variable should have had the value 'NA'. > > How can I input the value 'NA' present in a column in a CSV file without R > changing it to missing?I'd try na.strings="" (or maybe NULL or character(0)) -pd> > Thanks > > Nikhil > > [[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.-- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com