Re: [R] Creating a factor from a combination of vectors

2004-12-01 Thread Yves Brostaux
Thank you Richard, but I dismissed the 'ifelse' solution because it needs explicit manual definition of the factor levels and corresponding vectors' combinations and does not define it automaticaly from the 'cas' data-frame (from which values, number of levels and rownames can vary). Eric Lec

Re: [R] Creating a factor from a combination of vectors

2004-11-30 Thread Richard A. O'Keefe
Yves Brostaux <[EMAIL PROTECTED]> wrote: I want to produce a factor from a subset of the combination of two vectors. I have the vectors a et b in a data-frame : > df <- expand.grid(a=c(0, 5, 10, 25, 50), b=c(0, 25, 50, 100, 200)) ... and want to cr

Re: [R] Creating a factor from a combination of vectors

2004-11-30 Thread Gabor Grothendieck
Yves Brostaux fsagx.ac.be> writes: : : Dear list, : : Here's a little problem I already solved with my own coding style, but I : feel there is a more efficient and cleaner way to write it, but had no : success finding the "clever" solution. : : I want to produce a factor from a subset of the

Re: [R] Creating a factor from a combination of vectors

2004-11-30 Thread Eric Lecoutre
Hi Yves, Using your objects, here is a way: > cascombo=do.call("paste",c(cas,sep=".")) > factor(do.call("paste",c(df,sep=".")),levels=cascombo,labels=rownames(cas)) [1] Low Medium [16]High Levels: Low Medium High It uses: ? paste

[R] Creating a factor from a combination of vectors

2004-11-30 Thread Yves Brostaux
Dear list, Here's a little problem I already solved with my own coding style, but I feel there is a more efficient and cleaner way to write it, but had no success finding the "clever" solution. I want to produce a factor from a subset of the combination of two vectors. I have the vectors a et b