Hello,

Can anyone explain me what is wrong in the following code? and in particular 
why it is not 
possible to change the class of an object thanks to the function with(). Does 
an 
alternative exist?

xxx <- data.frame(x = c("a","b","c","d","e"), y = c("1","2","3","4","5"))
str(xxx)
with(xxx, {
        x <- as.character(x)
        y <- as.numeric(y)
})
str(xxx) #no effect on the class of x and y

xxx$x <- as.character(xxx$x)
xxx$y <- as.numeric(xxx$y)
str(xxx)

Thanks

François Michonnneau

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to