Thanks Josh. I'm quite new, just wondering re:factor levels? In this example (shamelessly stolen from the internet):
*schtyp* [1] 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 *schtyp.f <- factor(schtyp, labels = c("private", "public")) schtyp.f* [1] private private public private private private public private public [10] private public public public public private private public public [19] public private Levels: private public in my data i have a table: var1 var2 var3 cell1 x x x cell2 x x x cell3 x x x cell4 . . . . cell100 and i have a subset of those cells that are interesting to me as a list of data list1 = ["cell1, "cell5",cell19", "cell50", "cell70"] is it possible to create (similar to above): *schtyp.f <- factor(schtyp, labels = c("special", "normal")) so that when i plot this data, i can color the items in list1 as one color (eg all the special cells are red), and the rest of the items as a second color (eg all the other cells are black/blue)? Syb * On Tue, Mar 13, 2012 at 11:48 AM, Joshua Wiley <jwiley.ps...@gmail.com>wrote: > 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 <sybilkenne...@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@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/ > [[alternative HTML version deleted]] ______________________________________________ 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.