Dear All, I am trying to recode a variable using the functions provided by "memisc" package. Actually I am following the examples on page 9-10 of the vignette: -------------------------------------------------------------------------- d.fig <- within(d.fig,{ sev <- recode(sev, 1 -> 0.9, 2 -> 1.0, 3 -> 1.1, 4 -> 1.2, 5 -> 1.3, 6 -> 1.4, 7 -> 1.5, 8 -> 1.6, 9 -> 1.7, 10 -> 1.8, 11 -> 1.9, 12 -> 2.0, 13 -> 2.1, 14 -> 2.2, 15 -> 2.3, 16 -> 2.4, 17 -> 2.5, 18 -> 2.6, 19 -> 2.7, 20 -> 2.8, 21 -> 2.9, 22 -> 3.0, 23 -> 3.1, 24 -> 3.2, 25 -> 3.3, 26 -> 3.4) }) -------------------------------------------------------------------------- I keep get error message saying "Error in 0.9 <- 1 : invalid (do_set) left-hand side to assignment." Any idea what is going on? Thanks. Best, Shige
Shige Song wrote:> > Dear All, > > I am trying to recode a variable using the functions provided by > "memisc" package. Actually I am following the examples on page 9-10 of > the vignette: > > -------------------------------------------------------------------------- > d.fig <- within(d.fig,{ > sev <- recode(sev, > 1 -> 0.9, > 2 -> 1.0, > 3 -> 1.1, > ... and more > }) > -------------------------------------------------------------------------- > > I keep get error message saying "Error in 0.9 <- 1 : invalid (do_set) > left-hand side to assignment." Any idea what is going on? Thanks. >Please, make a shorter example and provide a data set. This works for me; library(memisc) d.fig = data.frame(sev=c(1,2,3)) d.fig <- within(d.fig,{ sev <- recode(sev, 1 -> 0.9, 2 -> 1.0) }) -- View this message in context: http://r.789695.n4.nabble.com/Recoding-using-the-memisc-package-tp3303700p3303742.html Sent from the R help mailing list archive at Nabble.com.
On 2011-02-13 07:05, Shige Song wrote:> Dear All, > > I am trying to recode a variable using the functions provided by > "memisc" package. Actually I am following the examples on page 9-10 of > the vignette: > > -------------------------------------------------------------------------- > d.fig<- within(d.fig,{ > sev<- recode(sev, > 1 -> 0.9, > 2 -> 1.0, > 3 -> 1.1, > 4 -> 1.2, > 5 -> 1.3, > 6 -> 1.4, > 7 -> 1.5, > 8 -> 1.6, > 9 -> 1.7, > 10 -> 1.8, > 11 -> 1.9, > 12 -> 2.0, > 13 -> 2.1, > 14 -> 2.2, > 15 -> 2.3, > 16 -> 2.4, > 17 -> 2.5, > 18 -> 2.6, > 19 -> 2.7, > 20 -> 2.8, > 21 -> 2.9, > 22 -> 3.0, > 23 -> 3.1, > 24 -> 3.2, > 25 -> 3.3, > 26 -> 3.4) > }) > -------------------------------------------------------------------------- > > I keep get error message saying "Error in 0.9<- 1 : invalid (do_set) > left-hand side to assignment." Any idea what is going on? Thanks.You might be stumbling into the recode() function in package car. It would be useful if you were to to follow the Posting Guide and provided you sessionInfo(). Peter Ehlers> > Best, > Shige > > ______________________________________________ > 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.