well thanks, when I post the mail I thought I got too simple example
which may be really replaced by "cut", but I thought about little more:
let say:
z = Which[x<10,x/3, 10<=x<20,0.5, 20<=x<100,x^2/(x-1)]
where there are both values and formula
sorry for mismatch and thanks for quick answer
Jarek
Henrique Dallazuanna pisze:
Try this;
cut(x, breaks = c(0, 10, 20, 100), labels = c(0.3, .5, 1))
On Tue, Sep 29, 2009 at 3:11 PM, Jarek Jasiewicz <jar...@amu.edu.pl> wrote:
Dear All!
I'm looking for equivalent of Matematica function "Which" which works as
follows:
z = Which[x<10,0.3, 10<=x<20,0.5, 20<=x<100,1]
where x is a vector
I can replace it with custom function with set of ifelse but I'm looking for
simpler and faster (much faster) solution
best wishes
Jarek
______________________________________________
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.
______________________________________________
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.