[R] sort list
Joshua Wiley
jwiley.psych at gmail.com
Tue Mar 13 12:48:35 CET 2012
Hi Sybil,
You cannot turn a list into a factor. You could do:
cell_data <-c('cell1','cell2')
factor_list <- factor(cell_data)
or if you already have a list, unlist() or as.vector() may convert it
into a vector that you can then convert to a factor.
Cheers,
Josh
On Tue, Mar 13, 2012 at 4:29 AM, sybil kennelly <sybilkennelly at gmail.com> wrote:
> Hello can anyone help please?
>
> i read two words "cell1", "cell2" into a list. I want to turn this list
> into a factor.
>
>> cell_data <-list(c('cell1','cell2'))
>
>
>> cell_data
> [[1]]
> [1] "cell1" "cell2"
>
>
>
>> factor_list <- factor(cell_data)
> Error in sort.list(y) : 'x' must be atomic for 'sort.list'
> Have you called 'sort' on a list?
>
>
>
>> sort.list(cell_data)
> Error in sort.list(cell_data) : 'x' must be atomic for 'sort.list'
> Have you called 'sort' on a list?
>
>
> Can anyone explain?
>
> Syb
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
More information about the R-help
mailing list