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
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
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
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
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