Re: [R] Can package plyr also calculate the mode?

2013-04-04 Thread ramoss
When I run  yy <- ddply(all,"ACTIVIT", summarise, mode=mode(COUNTS))

I get :  ACTIVITmode
XX  numeric
   ZZ  numeric
  & so on.



--
View this message in context: 
http://r.789695.n4.nabble.com/Can-package-plyr-also-calculate-the-mode-tp4663235p4663349.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Can package plyr also calculate the mode?

2013-04-04 Thread ramoss
When I put in mode=mode(COUNTS) I get the value "numeric" as an answer. I
think it's giving me the data type not the mode.



--
View this message in context: 
http://r.789695.n4.nabble.com/Can-package-plyr-also-calculate-the-mode-tp4663235p4663301.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Can package plyr also calculate the mode?

2013-04-03 Thread Sarah Goslee
My apologies: that's what happens when I don't start a clean session with
no packages loaded. (Also yet another argument for reproducible examples: I
always start a clean session to actualy create objects and run other
people's code.)

This might be of use (especially compared to my original answer!)
http://stackoverflow.com/questions/2547402/standard-library-function-in-r-for-finding-the-mode

Sarah

On Wednesday, April 3, 2013, Peter Ehlers wrote:

> On 2013-04-03 14:59, Sarah Goslee wrote:
>
>> Of course it can. Use the mode() in the same way you used the mean()
>> function.
>>
>> You didn't provide a reproducible example, so I can't provided tested
>> code, but I would think that you can add
>> mode=mode(COUNTS) to the ddply() arguments.
>>
>
> ?mode will direct you to the help page for _storage_ mode of an object.
> That's not likely what the OP had in mind. It seems that what s/he
> wants is the "most frequent value". This is (usually) a pretty useless
> piece of information, but there are a number of packages that do
> provide it.
>
> To the OP:
> Install package sos and then do findFn("mode") to see what's available.
> E.g. packages, pracma, asbio, dprep, rattle and many others.
> Do note that they handle the multimodal situation differently.
>
> Or, write your own, perhaps using table() and which.max().
>
> Peter Ehlers
>
>
>> all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
>>
>>>   q25=quantile(COUNTS,.25),**median=quantile(COUNTS,.50),
>>>>> q75=quantile(COUNTS,.75),
>>>>>q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
>>>>> q99=quantile(COUNTS,.99) )
>>>>>
>>>>
>>
>>
>> On Wed, Apr 3, 2013 at 5:36 PM, Mossadegh, Ramine N.
>>  wrote:
>>
>>> So you mean it cannot be calculated within plyer?
>>>
>>> -Original Message-
>>> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
>>> Sent: Wednesday, April 03, 2013 5:36 PM
>>> To: Mossadegh, Ramine N.; r-help
>>> Subject: Re: [R] Can package plyr also calculate the mode?
>>>
>>> If you type
>>> ?mode
>>> at an R prompt you will be able to read the help for the mode() function.
>>>
>>> On Wed, Apr 3, 2013 at 5:34 PM, Mossadegh, Ramine N.
>>>  wrote:
>>>
>>>> I tried mode=?mode(COUNTS) but that doesn't work.
>>>>
>>>> -Original Message-
>>>> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
>>>> Sent: Wednesday, April 03, 2013 5:32 PM
>>>> To: Mossadegh, Ramine N.
>>>> Cc: r-help
>>>> Subject: Re: [R] Can package plyr also calculate the mode?
>>>>
>>>> Sure, you can add the mode in, following the format by the other
>>>> summary statistics.
>>>>
>>>> ?mode
>>>>
>>>> Sarah
>>>>
>>>> On Wed, Apr 3, 2013 at 5:25 PM, ramoss 
>>>> wrote:
>>>>
>>>>> I am trying to replicate the SAS proc univariate in R.  I got most of
>>>>> the stats I needed for a by grouping in a data frame using:
>>>>>
>>>>> all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS),
>>>>> sd=sd(COUNTS),
>>>>>   q25=quantile(COUNTS,.25),**median=quantile(COUNTS,.50),
>>>>> q75=quantile(COUNTS,.75),
>>>>>q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
>>>>> q99=quantile(COUNTS,.99) )
>>>>> So I got the mean, median std dev, quantiles etc.
>>>>>
>>>>> IS there any way I can add the mode to the mixt. Thanks ahead for any
>>>>> suggestions.
>>>>>
>>>>>
>>>>>
>>>>>
>> --
>> Sarah Goslee
>> http://www.**functionaldiversity.org <http://www.functionaldiversity.org>
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[alternative HTML version deleted]]

__
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.


Re: [R] Can package plyr also calculate the mode?

2013-04-03 Thread Jim Lemon

On 04/04/2013 09:56 AM, Peter Ehlers wrote:

On 2013-04-03 14:59, Sarah Goslee wrote:

Of course it can. Use the mode() in the same way you used the mean()
function.

You didn't provide a reproducible example, so I can't provided tested
code, but I would think that you can add
mode=mode(COUNTS) to the ddply() arguments.


?mode will direct you to the help page for _storage_ mode of an object.
That's not likely what the OP had in mind. It seems that what s/he
wants is the "most frequent value". This is (usually) a pretty useless
piece of information, but there are a number of packages that do
provide it.

To the OP:
Install package sos and then do findFn("mode") to see what's available.
E.g. packages, pracma, asbio, dprep, rattle and many others.
Do note that they handle the multimodal situation differently.

Or, write your own, perhaps using table() and which.max().


The OP might find the Mode (note capital M) function (prettyR) helpful.

Jim

__
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.


Re: [R] Can package plyr also calculate the mode?

2013-04-03 Thread Peter Ehlers

On 2013-04-03 14:59, Sarah Goslee wrote:

Of course it can. Use the mode() in the same way you used the mean() function.

You didn't provide a reproducible example, so I can't provided tested
code, but I would think that you can add
mode=mode(COUNTS) to the ddply() arguments.


?mode will direct you to the help page for _storage_ mode of an object.
That's not likely what the OP had in mind. It seems that what s/he
wants is the "most frequent value". This is (usually) a pretty useless
piece of information, but there are a number of packages that do
provide it.

To the OP:
Install package sos and then do findFn("mode") to see what's available.
E.g. packages, pracma, asbio, dprep, rattle and many others.
Do note that they handle the multimodal situation differently.

Or, write your own, perhaps using table() and which.max().

Peter Ehlers



all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),

  q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
q75=quantile(COUNTS,.75),
   q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
q99=quantile(COUNTS,.99) )




On Wed, Apr 3, 2013 at 5:36 PM, Mossadegh, Ramine N.
 wrote:

So you mean it cannot be calculated within plyer?

-Original Message-
From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
Sent: Wednesday, April 03, 2013 5:36 PM
To: Mossadegh, Ramine N.; r-help
Subject: Re: [R] Can package plyr also calculate the mode?

If you type
?mode
at an R prompt you will be able to read the help for the mode() function.

On Wed, Apr 3, 2013 at 5:34 PM, Mossadegh, Ramine N.
 wrote:

I tried mode=?mode(COUNTS) but that doesn't work.

-Original Message-
From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
Sent: Wednesday, April 03, 2013 5:32 PM
To: Mossadegh, Ramine N.
Cc: r-help
Subject: Re: [R] Can package plyr also calculate the mode?

Sure, you can add the mode in, following the format by the other summary 
statistics.

?mode

Sarah

On Wed, Apr 3, 2013 at 5:25 PM, ramoss  wrote:

I am trying to replicate the SAS proc univariate in R.  I got most of
the stats I needed for a by grouping in a data frame using:

all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
  q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
q75=quantile(COUNTS,.75),
   q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
q99=quantile(COUNTS,.99) )
So I got the mean, median std dev, quantiles etc.

IS there any way I can add the mode to the mixt. Thanks ahead for any
suggestions.





--
Sarah Goslee
http://www.functionaldiversity.org

__
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.


Re: [R] Can package plyr also calculate the mode?

2013-04-03 Thread Sarah Goslee
Of course it can. Use the mode() in the same way you used the mean() function.

You didn't provide a reproducible example, so I can't provided tested
code, but I would think that you can add
mode=mode(COUNTS) to the ddply() arguments.

all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
>>>  q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
>>> q75=quantile(COUNTS,.75),
>>>   q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
>>> q99=quantile(COUNTS,.99) )



On Wed, Apr 3, 2013 at 5:36 PM, Mossadegh, Ramine N.
 wrote:
> So you mean it cannot be calculated within plyer?
>
> -Original Message-
> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
> Sent: Wednesday, April 03, 2013 5:36 PM
> To: Mossadegh, Ramine N.; r-help
> Subject: Re: [R] Can package plyr also calculate the mode?
>
> If you type
> ?mode
> at an R prompt you will be able to read the help for the mode() function.
>
> On Wed, Apr 3, 2013 at 5:34 PM, Mossadegh, Ramine N.
>  wrote:
>> I tried mode=?mode(COUNTS) but that doesn't work.
>>
>> -Original Message-
>> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
>> Sent: Wednesday, April 03, 2013 5:32 PM
>> To: Mossadegh, Ramine N.
>> Cc: r-help
>> Subject: Re: [R] Can package plyr also calculate the mode?
>>
>> Sure, you can add the mode in, following the format by the other summary 
>> statistics.
>>
>> ?mode
>>
>> Sarah
>>
>> On Wed, Apr 3, 2013 at 5:25 PM, ramoss  wrote:
>>> I am trying to replicate the SAS proc univariate in R.  I got most of
>>> the stats I needed for a by grouping in a data frame using:
>>>
>>> all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
>>>  q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
>>> q75=quantile(COUNTS,.75),
>>>   q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
>>> q99=quantile(COUNTS,.99) )
>>> So I got the mean, median std dev, quantiles etc.
>>>
>>> IS there any way I can add the mode to the mixt. Thanks ahead for any
>>> suggestions.
>>>
>>>
>>>

--
Sarah Goslee
http://www.functionaldiversity.org

__
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.


Re: [R] Can package plyr also calculate the mode?

2013-04-03 Thread Sarah Goslee
If you type
?mode
at an R prompt you will be able to read the help for the mode() function.

On Wed, Apr 3, 2013 at 5:34 PM, Mossadegh, Ramine N.
 wrote:
> I tried mode=?mode(COUNTS) but that doesn't work.
>
> -Original Message-
> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
> Sent: Wednesday, April 03, 2013 5:32 PM
> To: Mossadegh, Ramine N.
> Cc: r-help
> Subject: Re: [R] Can package plyr also calculate the mode?
>
> Sure, you can add the mode in, following the format by the other summary 
> statistics.
>
> ?mode
>
> Sarah
>
> On Wed, Apr 3, 2013 at 5:25 PM, ramoss  wrote:
>> I am trying to replicate the SAS proc univariate in R.  I got most of
>> the stats I needed for a by grouping in a data frame using:
>>
>> all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
>>  q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
>> q75=quantile(COUNTS,.75),
>>   q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
>> q99=quantile(COUNTS,.99) )
>> So I got the mean, median std dev, quantiles etc.
>>
>> IS there any way I can add the mode to the mixt. Thanks ahead for any
>> suggestions.
>>
>>
>>


--
Sarah Goslee
http://www.functionaldiversity.org

__
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.


Re: [R] Can package plyr also calculate the mode?

2013-04-03 Thread Sarah Goslee
Sure, you can add the mode in, following the format by the other
summary statistics.

?mode

Sarah

On Wed, Apr 3, 2013 at 5:25 PM, ramoss  wrote:
> I am trying to replicate the SAS proc univariate in R.  I got most of the
> stats I needed for a by grouping in a data frame using:
>
> all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
>  q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
> q75=quantile(COUNTS,.75),
>   q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
> q99=quantile(COUNTS,.99) )
> So I got the mean, median std dev, quantiles etc.
>
> IS there any way I can add the mode to the mixt. Thanks ahead for any
> suggestions.
>
>
>

--
Sarah Goslee
http://www.functionaldiversity.org

__
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] Can package plyr also calculate the mode?

2013-04-03 Thread ramoss
I am trying to replicate the SAS proc univariate in R.  I got most of the
stats I needed for a by grouping in a data frame using:

all1 <- ddply(all,"ACT_NAME", summarise, mean=mean(COUNTS), sd=sd(COUNTS),
 q25=quantile(COUNTS,.25),median=quantile(COUNTS,.50),
q75=quantile(COUNTS,.75),
  q90=quantile(COUNTS,.90), q95=quantile(COUNTS,.95),
q99=quantile(COUNTS,.99) )
So I got the mean, median std dev, quantiles etc.  

IS there any way I can add the mode to the mixt. Thanks ahead for any
suggestions.



--
View this message in context: 
http://r.789695.n4.nabble.com/Can-package-plyr-also-calculate-the-mode-tp4663235.html
Sent from the R help mailing list archive at Nabble.com.

__
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.