Dear List,

I'm having a curious problem with lapply(). I've used it before to convert a subset of columns in my dataframe, to factors, and its worked. But now, on re-running the identical code as before it just doesn't convert the columns into factors at all.

As far as I can see I've done nothing different, and its strange that it shouldn't do the action.

Has anybody come across this before? Any input on this strange issue much appreciated..

Hope I haven't missed something obvious.

Thanks a lot,

Aditi

(P.s.- I've tried converting columns one by one to factors this time, and that works.

P1L55<-factor(P1L55)
levels(P1L55)
[1] "0" "1"

Code:

prm<-read.table("P:\\.....  .csv", header=T, ...sep=",", ...)

prmdf<-data.frame(prm)

prmdf[2:13]<-lapply(prmdf[2:13], factor) ## action performed, no error message

##I tried to pick random columns and check

levels(P1L55)
NULL

is.factor(P1L96)
FALSE


----------------------
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

______________________________________________
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.

Reply via email to