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 it.
Many thanks to all
> 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 constructive discussion .
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 may
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 problem
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 15, 2015, at 7:20 PM, Charl
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) se
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 not
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 abo
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) + (ASB
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, Maria
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
$ASB,
>> 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 P
rtured:
> mapply( function(x,y) switch(x, A=y*2, B=y+3, C=sqrt(y) ), dat$ASB, 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: Tuesda
d L Carlson
> Department of Anthropology
> Texas A&M University
> College 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 Alspa
gt;> dat$Flow * mult[match(dat$ASB, cat)]
>> [1] 1.151 1.380 2.100
>>
>> -
>> David L Carlson
>> Department of Anthropology
>> Texas A&M University
>> College Station, TX 77840-4352
>>
>>
>> -Original Me
0-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
>
> ... but this o
t;
> 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,
>
> I am writin
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 your help. I have a
-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
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 r
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 ...
21 matches
Mail list logo