[R] Interquartile Range
Jim Lemon
drjimlemon at gmail.com
Tue Apr 19 04:02:13 CEST 2016
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 <michaeleartz at gmail.com> wrote:
> 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) #Function I wrote for getting the
> mode shown below
>
> ,col3_Range=paste(as.character(round(quantile(datat$tenure,c(.25)))),
> as.character(round(quantile(data$tenure,c(.75)))), sep = "-")
> )
>
> #custom Mode function
> Mode <- function(x) {
> ux <- unique(x)
> ux[which.max(tabulate(match(x, ux)))]
> }
>
> I am not sre what is going wrong on my interquartile range function, it
> works on its own outside of ddply()
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
More information about the R-help
mailing list