[R] concatenating factor from list

2006-03-15 Thread Sebastian Luque
Hi, I've run into a ridiculous problem I can't find any solutions for in the archives or help pages: data(barley) cutYield - with(barley, by(yield, variety, cut, breaks = c(0, 30, 60, 90))) As in this example, I'm using 'by' to return a factor for each level of another factor. The problem is

Re: [R] concatenating factor from list

2006-03-15 Thread Gabor Grothendieck
Is this ok or is it what you are trying to avoid: factor(unlist(lapply(cutYield, as.character))) On 3/15/06, Sebastian Luque [EMAIL PROTECTED] wrote: Hi, I've run into a ridiculous problem I can't find any solutions for in the archives or help pages: data(barley) cutYield -

Re: [R] concatenating factor from list

2006-03-15 Thread Sebastian Luque
Gabor Grothendieck [EMAIL PROTECTED] wrote: Is this ok or is it what you are trying to avoid: factor(unlist(lapply(cutYield, as.character))) Thank you Gabor. The problem with that is what if some levels do not appear in any member of cutYield? In that case, the factor created above would

Re: [R] concatenating factor from list

2006-03-15 Thread Gabor Grothendieck
Since all components of cutYield have the same levels, one could do this to ensure that all levels are represented: factor(unlist(lapply(cutYield, as.character)), levels = levels(cutYield[[1]])) On 3/15/06, Sebastian Luque [EMAIL PROTECTED] wrote: Gabor Grothendieck [EMAIL PROTECTED] wrote:

Re: [R] concatenating factor from list

2006-03-15 Thread Sebastian Luque
Sebastian Luque [EMAIL PROTECTED] wrote: Gabor Grothendieck [EMAIL PROTECTED] wrote: Is this ok or is it what you are trying to avoid: factor(unlist(lapply(cutYield, as.character))) Thank you Gabor. The problem with that is what if some levels do not appear in any member of cutYield?

Re: [R] concatenating factor from list

2006-03-15 Thread Gabor Grothendieck
On 3/15/06, Sebastian Luque [EMAIL PROTECTED] wrote: Sebastian Luque [EMAIL PROTECTED] wrote: Gabor Grothendieck [EMAIL PROTECTED] wrote: Is this ok or is it what you are trying to avoid: factor(unlist(lapply(cutYield, as.character))) Thank you Gabor. The problem with that is what if