> On 17 Sep 2015, at 01:42, Dénes Tóth wrote:
>
>
>
> On 09/16/2015 04:41 PM, Bert Gunter wrote:
>> Yes! Chuck's use of mapply is exactly the split/combine strategy I was
>> looking for. In retrospect, exactly how one should think about it.
>> Many thanks to all for a
On Thu, 17 Sep 2015, Berend Hasselman wrote:
On 17 Sep 2015, at 01:42, Dénes Tóth wrote:
On 09/16/2015 04:41 PM, Bert Gunter wrote:
Yes! Chuck's use of mapply is exactly the split/combine strategy I was
looking for. In retrospect, exactly how one should think about
I think a more common idiom for the simpler case would be to use indexing
vals <- c(0.1, 0.15, 0.2)
mult <- vals[ASBclass]
(However, some people are on the move to enforce
mult <- vals[as.numeric(ASBclass)]
because people who confuse factors and character variables get even more
confused
Hi,
I guess this might work too and might be quite speedy:
ASBclass = factor(c(1,2,2,3,2,1))
Flow = c(1,1,1,1,1,1)
mult = ((ASBclass==1) * 0.1 + (ASBclass==2) * 0.15 + (ASBclass==3) * 0.2)
deviation = mult * Flow
or with the more complex arithmetic:
deviation = ((ASBclass==1) * (Flow*2) +
Yes! Chuck's use of mapply is exactly the split/combine strategy I was
looking for. In retrospect, exactly how one should think about it.
Many thanks to all for a constructive discussion .
-- Bert
Bert Gunter
"Data is not information. Information is not knowledge. And knowledge
is certainly
I assume it's to return the vectors in their original order.
-- Bert
Bert Gunter
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
-- Clifford Stoll
On Wed, Sep 16, 2015 at 2:10 PM, David Winsemius wrote:
>
> On Sep
On Sep 15, 2015, at 7:20 PM, Charles C. Berry wrote:
> On Tue, 15 Sep 2015, Bert Gunter wrote:
>
>> Thanks to both Davids.
>>
>> I realize that these things are often a matter of aesthetics -- and
>> hence have little rational justification -- but I agree with The Other
>> David: eval(parse)
On 09/16/2015 04:41 PM, Bert Gunter wrote:
Yes! Chuck's use of mapply is exactly the split/combine strategy I was
looking for. In retrospect, exactly how one should think about it.
Many thanks to all for a constructive discussion .
-- Bert
Bert Gunter
Use mapply like this on large
Dénes:
A fair point! The only reason I have is ignorance -- I have not used
data.table. I am not surprised that it and perhaps other packages
(dplyr maybe?) can do things in a reasonable way very efficiently. The
only problem is that it requires us to learn yet another
package/paradigm. There
Hi Maria,
Why not exploit some simple boolean facts (FALSE=0, TRUE=1) in your
calculation, so
ASBclass = c(1,2,2,3,2,1)
Flow = c(1,1,1,1,1,1)
factor = ((ASBclass==1) * 0.1 + (ASBclass==2) * 0.15 + (ASBclass==3) * 0.2)
deviation = factor * Flow
cheers
Peter
> On 15 Sep 2015, at 12:56,
15 4:43 PM
> To: David L Carlson <dcarl...@tamu.edu>
> Cc: Peter Alspach <peter.alsp...@plantandfood.co.nz>; r-help@r-project.org
> Subject: Re: [R] Multiple if function
>
> Thanks, David.
>
> I would say, not quite.
>
> What if the alternatives are:
>
&g
avid L Carlson <dcarl...@tamu.edu>
Cc: Peter Alspach <peter.alsp...@plantandfood.co.nz>; r-help@r-project.org
Subject: Re: [R] Multiple if function
Thanks, David.
I would say, not quite.
What if the alternatives are:
If class = "a" multiply y by 2;
If class = "b" add 5
On Tue, 15 Sep 2015, Bert Gunter wrote:
Thanks to both Davids.
I realize that these things are often a matter of aesthetics -- and
hence have little rational justification -- but I agree with The Other
David: eval(parse) seems to me to violate R's soul( it makes R a macro
language instead of a
dat$Flow )
>ABC
> 23.02000 12.2 3.24037
>
> Best;
> The Other David
>
>>
>> David
>>
>> -Original Message-
>> From: Bert Gunter [mailto:bgunter.4...@gmail.com]
>> Sent: Tuesday, September 15, 2015 4:43 PM
>&
lege Station, TX 77840-4352
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
> Sent: Tuesday, September 15, 2015 3:51 PM
> To: Peter Alspach
> Cc: r-help@r-project.org
> Subject: Re: [R] Multiple if function
>
&
>> cat <- LETTERS[1:3]
>>> mult <- c(.1, .15, .2)
>>> dat$Flow * mult[match(dat$ASB, cat)]
>> [1] 1.151 1.380 2.100
>>
>> -
>> David L Carlson
>> Department of Anthropology
>> Texas A Universit
Dear all,
I am writing as I would like your help. I have a dataframe with two columns,
ASB and Flow, where the the first one has values 1, 2 or 3 and the second flow
data. Something like that:
ASBclass Flow1 11.51 9.2
2 10.5
3 6.7 ...
Maria:
Have you read An Intro to R or other R tutorial? There are many on the
web and this is a basic idea that they would explain (with examples).
?ifelse ##a vectorized kind of if conditional
is one way to do this (though it can get a little convoluted). There
are others (e.g. splitting and
-project.org
Subject: [R] Multiple if function
Dear all,
I am writing as I would like your help. I have a dataframe with two columns,
ASB and Flow, where the the first one has values 1, 2 or 3 and the second flow
data. Something like that:
ASBclass Flow1 11.51 9.2
2
> HTH
>
> Peter Alspach
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maria Lathouri
> Sent: Tuesday, 15 September 2015 10:57 p.m.
> To: r-help@r-project.org
> Subject: [R] Multiple if function
>
> Dear all,
>
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maria Lathouri
> Sent: Tuesday, 15 September 2015 10:57 p.m.
> To: r-help@r-project.org
> Subject: [R] Multiple if function
>
> Dear all,
>
> I am writing as I would like
21 matches
Mail list logo