1) Give us a reproducible example.
2) You probably don't want to use attach.
3) Yes there is a way, but without an example, it's hard to say what
will work. Assume a data.frame called df, maybe something like the
following, which is untested...
df[is.factor(df)] <- lapply(df[is.factor(df)], function(x)
as.numeric(as.character(x)))
aledanda wrote:
Hi,
Is there a way to recursively change the variables imported with
read.table(..) - and then attached with attach(..) - from as.factor to
as.integer?
I have about 9 variables that are now recognized as factors but I need to do
statistics on them so I need to change them in as.integer. It works, but I
wonder if there is a way to to this for all the variables in one go.
Thanks a lot for your help
Ale
______________________________________________
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.