[R] Equivalent for Matematica function Which...
Jarek Jasiewicz
jarekj at amu.edu.pl
Tue Sep 29 20:36:05 CEST 2009
well function arguments are in square brackets. z is result (new
vector). I show Matematica syntax, but cannot explain what I expect. Sorry
The example is wrong because it can be replaced by R cut function. The
arguments are: condition,action.... and can be replaced by ste of ifelse
formulas:
if (x<10) x<-0.7
else if (x<30 && x=>10) x<-x^2/(x-1)
etc...
but that solution is slow for vectors with millions of numbers
thanks
Jarek
Erik Iverson pisze:
> Hello,
>
>
>> 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
>>
>
> Unless someone happens to be a Mathematica user (very possible), I don't know how we would answer the question. You give an example of the function call, but not what the function arguments or return value are.
>
> There is an R function called "which", but what the Mathematica "Which" is doing is entirely mysterious from your example. What is in "z" for instance??
>
More information about the R-help
mailing list