Re: [R] lapply() not converting columns to factors (no error message)
Sorry, my file is at: http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html -- 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.
Re: [R] lapply() not converting columns to factors (no error message)
Works for me: x - read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Testvcomp10.csv?tsid=20091116-075223-c3093ab0;)) names(x) x[2:13] - lapply(x[2:13], factor) levels(x$P1L55) [1] 0 1 is.factor(x$P1L96) [1] TRUE sessionInfo() R version 2.10.0 (2009-10-26) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-26 loaded via a namespace (and not attached): [1] grid_2.10.0 tools_2.10.0 On Mon, Nov 16, 2009 at 4:50 AM, A Singh aditi.si...@bristol.ac.uk wrote: Sorry, my file is at: http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html -- 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. __ 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.
Re: [R] lapply() not converting columns to factors (no error message)
Oh, strange! I thought it might be a problem with the 'base' package installation, because the same thing's worked for me too before but won't do now. I tried to reinstall it (base), but R says its there already which I expected it to be anyway. I don't quite know where the issue is. Very odd. --On 16 November 2009 04:59 -0800 Sundar Dorai-Raj sdorai...@gmail.com wrote: Works for me: x - read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Testvc omp10.csv?tsid=20091116-075223-c3093ab0)) names(x) x[2:13] - lapply(x[2:13], factor) levels(x$P1L55) [1] 0 1 is.factor(x$P1L96) [1] TRUE sessionInfo() R version 2.10.0 (2009-10-26) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-26 loaded via a namespace (and not attached): [1] grid_2.10.0 tools_2.10.0 On Mon, Nov 16, 2009 at 4:50 AM, A Singh aditi.si...@bristol.ac.uk wrote: Sorry, my file is at: http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html -- 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. -- 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.
Re: [R] lapply() not converting columns to factors (no error message)
Didn't you notice the difference between Sundar's code and yours? Sundar put the data.frame name before the column name while you did not do so in your check step. -- DW On Nov 16, 2009, at 8:07 AM, A Singh wrote: Oh, strange! I thought it might be a problem with the 'base' package installation, because the same thing's worked for me too before but won't do now. I tried to reinstall it (base), but R says its there already which I expected it to be anyway. I don't quite know where the issue is. Very odd. --On 16 November 2009 04:59 -0800 Sundar Dorai-Raj sdorai...@gmail.com wrote: Works for me: x - read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Testvc omp10.csv?tsid=20091116-075223-c3093ab0)) names(x) x[2:13] - lapply(x[2:13], factor) levels(x$P1L55) [1] 0 1 is.factor(x$P1L96) [1] TRUE sessionInfo() R version 2.10.0 (2009-10-26) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-26 loaded via a namespace (and not attached): [1] grid_2.10.0 tools_2.10.0 On Mon, Nov 16, 2009 at 4:50 AM, A Singh aditi.si...@bristol.ac.uk wrote: Sorry, my file is at: http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html -- 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. -- 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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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.
Re: [R] lapply() not converting columns to factors (no error message)
Could it be you have factor redefined in your workspace? Have you tried it in a clean directory? I.e. a directory where no .RData exists? On Mon, Nov 16, 2009 at 5:07 AM, A Singh aditi.si...@bristol.ac.uk wrote: Oh, strange! I thought it might be a problem with the 'base' package installation, because the same thing's worked for me too before but won't do now. I tried to reinstall it (base), but R says its there already which I expected it to be anyway. I don't quite know where the issue is. Very odd. --On 16 November 2009 04:59 -0800 Sundar Dorai-Raj sdorai...@gmail.com wrote: Works for me: x - read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Testvc omp10.csv?tsid=20091116-075223-c3093ab0)) names(x) x[2:13] - lapply(x[2:13], factor) levels(x$P1L55) [1] 0 1 is.factor(x$P1L96) [1] TRUE sessionInfo() R version 2.10.0 (2009-10-26) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-26 loaded via a namespace (and not attached): [1] grid_2.10.0 tools_2.10.0 On Mon, Nov 16, 2009 at 4:50 AM, A Singh aditi.si...@bristol.ac.uk wrote: Sorry, my file is at: http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html -- 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. -- 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.
Re: [R] lapply() not converting columns to factors (no error message)
Oh yes. Did notice that now. Thanks for pointing that out. I was a bit concerned because that's a crucial step for running further lmer models, and that isn't working too, based on this factoring of columns. Will hopefully be able to weed it out. Am sorry if this wasted a bit of time. I realized that summary(prmdf) gives me what I need. Thanks a lot, Aditi --On 16 November 2009 08:17 -0500 David Winsemius dwinsem...@comcast.net wrote: Didn't you notice the difference between Sundar's code and yours? Sundar put the data.frame name before the column name while you did not do so in your check step. -- DW On Nov 16, 2009, at 8:07 AM, A Singh wrote: Oh, strange! I thought it might be a problem with the 'base' package installation, because the same thing's worked for me too before but won't do now. I tried to reinstall it (base), but R says its there already which I expected it to be anyway. I don't quite know where the issue is. Very odd. --On 16 November 2009 04:59 -0800 Sundar Dorai-Raj sdorai...@gmail.com wrote: Works for me: x - read.csv(url(http://dc170.4shared.com/download/153147281/a5c78386/Test vc omp10.csv?tsid=20091116-075223-c3093ab0)) names(x) x[2:13] - lapply(x[2:13], factor) levels(x$P1L55) [1] 0 1 is.factor(x$P1L96) [1] TRUE sessionInfo() R version 2.10.0 (2009-10-26) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-26 loaded via a namespace (and not attached): [1] grid_2.10.0 tools_2.10.0 On Mon, Nov 16, 2009 at 4:50 AM, A Singh aditi.si...@bristol.ac.uk wrote: Sorry, my file is at: http://www.4shared.com/file/153147281/a5c78386/Testvcomp10.html -- 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. -- 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. David Winsemius, MD Heritage Laboratories West Hartford, CT -- 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.
Re: [R] lapply() not converting columns to factors (no error message)
A Singh wrote: 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 Make sure that you are looking in the same object that you changed. E.g. attach(prmdf) prmdf[2:13]-lapply(prmdf[2:13], factor) levels(P1L55) is not going to work levels(prmdf$P1L55) should, or attaching _after_ the change. Also, make sure that you don't have P1L55 et al. sitting in the global enviromnent. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ 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.