Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread Henrique Dallazuanna
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 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 vec

Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread Jorge Ivan Velez
Hi Jarek, Take a look at ?which, ?ifelse and ?recode (car package). HTH, Jorge On Tue, Sep 29, 2009 at 2:11 PM, Jarek Jasiewicz <> 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] > > wh

Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread Erik Iverson
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

Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread Jarek Jasiewicz
William Dunlap pisze: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jarek Jasiewicz Sent: Tuesday, September 29, 2009 11:36 AM To: Erik Iverson Cc: R-help@r-project.org Subject: Re: [R] Equivalent for Matematica function

Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread David Winsemius
On Sep 29, 2009, at 2:36 PM, Jarek Jasiewicz wrote: 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,ac

Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jarek Jasiewicz > Sent: Tuesday, September 29, 2009 11:36 AM > To: Erik Iverson > Cc: R-help@r-project.org > Subject: Re: [R] Equivalent for Mate

Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread Jarek Jasiewicz
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:

Re: [R] Equivalent for Matematica function Which...

2009-09-29 Thread Jarek Jasiewicz
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 Ja