thanks for your suggestions, which work. In addition, I updated Rstudio to the latest version and my old code works again.
Best, Aurelien 2012/3/14 Petr Savicky <savi...@cs.cas.cz> > On Wed, Mar 14, 2012 at 03:07:19PM -0700, Aurélien PHILIPPOT wrote: > > Dear R experts, > > I have a dataframe imported from a csv file (with read.csv). > > > > Here is an example: > > > > yyyymm<- c("19860228", "19860331","19860430","19860531") > > id<-c("10000","10000","10000","10000") > > re<- c("C","0.25", "0.98", "1.34") > > > > mret<-data.frame(yyyymm, id, re) > > > > mret<-as.numeric(as.character(mret$re)) > > Error: (converted from warning) NAs introduced by coercion > > > > > > One of the column ("re" in the example above) has characters and numbers, > > but it should be treated a numeric column. Therefore, I want to eliminate > > the rows in which the variable re has characters values (the first row in > > the example). > > In the past, I always used this code successfully (the characters were > > replaced by NA, and only a warning message was issued). But now, I have > an > > error message and it no longer works. Could anyone suggest an alternative > > way to do it? > > Hi. > > You probably have options(warn=2) set. This may be checked > using getOption("warn"). If you set options(warn=0), then > the warning will not be converted to an error. > > Hope this helps. > > Petr Savicky. > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]]
______________________________________________ R-help@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.