Just for the record, you do not need cbind(): wind <- data.frame(windSpeed,windDirec)
Using cbind() does not create a problem as long as the columns are all numeric, but if your data frame contains a mixture of numeric, factor, and character columns, cbind() will mess things up. ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Alexandra Catena Sent: Monday, February 23, 2015 11:50 AM To: Frederic Ntirenganya Cc: r-help@r-project.org Subject: Re: [R] Replacing 9999 and 999 values with NA The command, data[data ==9999] <- NA, worked! Thank you! But just in case you wanted to know, I'm downloading the data and unzipping it through readLines. I then concatenate two columns ( wind speed and direction) from the unzipped data through cbind but I make it into a data frame. wind = data.frame(cbind(windSpeed,windDirec)) Thanks, Alexandra On Sat, Feb 21, 2015 at 10:38 PM, Frederic Ntirenganya <ntfr...@gmail.com> wrote: > If you are reading the data frame using for instance read.csv, you can put > in the argument na.string ="9999". > Another way to do that is data[data ==9999] <- NA. > > It should be good to tell us how you are reading your dataset. > > On Feb 21, 2015 6:49 AM, "Jeff Newmiller" <jdnew...@dcn.davis.ca.us> wrote: >> >> You did not say how you imported the data, but if you used one of the >> read.table variants (including read.csv) then you can use the na.strings >> argument as documented in the help file for read.table. >> >> Next time please read the posting guide, as there are some useful tips in >> there, such as posting using plain text (a setting in your email program) so >> we don't get garbled info from you, and providing a reproducible example. >> >> --------------------------------------------------------------------------- >> Jeff Newmiller The ..... ..... Go >> Live... >> DCN:<jdnew...@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 February 20, 2015 10:55:30 AM PST, Alexandra Catena <amc5...@gmail.com> >> wrote: >> >Hello All, >> > >> >I have a data frame of two columns for wind. The first column is for >> >wind >> >speed and the second wind direction. I'm trying to replace the 9999 >> >values >> >in the first column and the 999 values in the second column with NA. I >> >tried to use the function ltdl.fix.df but it doesn't seem to do >> >anything. >> > >> >> ltdl.fix.df(windMV, zero2na = FALSE, coded = 999) >> > >> > n = 9432 by p = 4 matrix checked, 0 NA(s) present >> > >> > 0 factor variable(s) present >> > >> > 5675 value(s) coded 999 set to NA >> > >> > 0 -ve value(s) set to +ve half the negative value >> > >> > >> >I have R version 3.1.1 >> > >> >Thanks, >> >Alexandra >> > >> > [[alternative HTML version deleted]] >> > >> >______________________________________________ >> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> >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. >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.