I already found a solution, you suggested I try to find a non hacky
solution, which was not really my priority. I should have declined
politely, which I will do now. Or, ifyou just want me to post reproducible
code because you are bored or because you like solving problems then let me
know and I wi
???
IQR returns a single number.
> IQR(rnorm(10))
[1] 1.090168
To your 2nd response:
"I could have used average, min, max, they all would have returned the
same thing., "
I can only respond: huh?? Are all your values identical?
You really need to provide a small reproducible example as request
Again, IQR returns two both a .25 and a .75 value and it failed, which is
why I didn't use it before. Also, the first function just returns tha same
value repeating. Since they are the same, before the second call, using
the mode function is just a way to grab one value. I could have used
average,
Hi,
Jumping into this thread mainly on the point of the mode of the distribution,
while also supporting Bert's comments below on theory.
If the vector 'x' that is being passed to this function is an integer vector,
then a tabulation of the integers can yield a 'mode', presuming of course that
Well, instead of your functions try:
Mode <- function(x) {
tabx <- table(x)
tabx[which.max(tabx)]
}
and use R's IQR function instead of yours.
... so I still don't get why you want to return a character string
instead of a value for the IQR;
and the mode of a sample defined as above is
Hi,
Here is what I am doing
notGroupedAll <- ddply(data
,~groupColumn
,summarise
,col1_mean=mean(col1)
,col2_mode=Mode(col2) #Function I wrote for getting the
mode shown below
,col3_Range=myIqr(col3)
If you show us, not just tell us about, a self-contained example
someone might show you a non-hacky way of getting the job done.
(I don't see an argument to plyr::ddply called 'transform'.)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Apr 19, 2016 at 12:18 PM, Michael Artz
wrote:
> Oh t
Oh thanks for that clarification Bert! Hope you enjoyed your coffee! I
ended up just using the transform argument in the ddply function. It
worked and it repeated, then I called a mode function in another call to
ddply that summarised. Kinda hacky but oh well!
On Tue, Apr 19, 2016 at 12:31 PM,
... and I'm getting another cup of coffee...
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Apr 19, 2016 at 10:30 AM, Bert Gunter wrote:
> NO NO
NO NO -- I am wrong! The paste() expression is of course evaluated.
It's just that a character string is returned of the form "something -
something".
I apologize for the confusion.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking thing
To be precise:
paste(round(quantile(x,0.25),0),round(quantile(x,0.75),0),sep="-")
is an expression that evaluates to a character string:
"round(quantile(x,.25),0) - round(quantile(x,0.75),0)"
no matter what the argument of your function, x. Hence
return(paste(...)) will return this exact charac
Can you show us a self-contained example, along with the output of
running conflicts()?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Apr 19, 2016 at 8:57 AM, Michael Artz
wrote:
> HI that did not work for me either. The value I got returned from that
> function was " - " :(. thanks fo
HI that did not work for me either. The value I got returned from that
function was " - " :(. thanks for the reply
through
On Tue, Apr 19, 2016 at 10:34 AM, William Dunlap wrote:
> > That didn't work Jim!
>
> It always helps to say how the suggestion did not work. Jim's
> function had a typo
> That didn't work Jim!
It always helps to say how the suggestion did not work. Jim's
function had a typo in it - was that the problem? Or did you not
change the call to ddply to use that function. Here is something
that might "work" for you:
library(plyr)
data <- data.frame(groupColumn=rep
Hi bert,
I understand the difference between a character string and a number. I need
to return a character string, that is a requirement. It needs to be in
that format. Getting the range with IQR is trivial I already tried it. The
grouping function accepts only one return value, and IQR returns
Are you aware that there *already is* a function that does this?
?IQR
(also your "function" iqr" is just a character string and would have
to be parsed and evaluated to become a function. But this is a
TERRIBLE way to do things in R as it completely circumvents R's
central functional programming
That didn't work Jim!
Thanks anyway
On Mon, Apr 18, 2016 at 9:02 PM, Jim Lemon wrote:
> Hi Michael,
> At a guess, try this:
>
> iqr<-function(x) {
> return(paste(round(quantile(x,0.25),0),round(quantile(x,0.75),0),sep="-")
> }
>
> .col3_Range=iqr(datat$tenure)
>
> Jim
>
>
>
> On Tue, Apr 19, 2
Hi Michael,
At a guess, try this:
iqr<-function(x) {
return(paste(round(quantile(x,0.25),0),round(quantile(x,0.75),0),sep="-")
}
.col3_Range=iqr(datat$tenure)
Jim
On Tue, Apr 19, 2016 at 11:15 AM, Michael Artz wrote:
> Hi,
> I am trying to show an interquartile range while grouping values
Hi,
I am trying to show an interquartile range while grouping values using
the function ddply(). So my function call now is like
groupedAll <- ddply(data
,~groupColumn
,summarise
,col1_mean=mean(col1)
,col2_mode=Mode(col2) #Fun
19 matches
Mail list logo