[R] Error when using median as aggregation function in dcast

arun smartpink111 at yahoo.com
Wed Jun 26 14:20:07 CEST 2013

Please check this link:

----- Original Message -----
From: Johannes Radinger <johannesradinger at gmail.com>
To: R help <r-help at r-project.org>
Sent: Wednesday, June 26, 2013 4:36 AM
Subject: [R] Error when using median as aggregation function in dcast


I am trying to calculated various summary statistics using the dcast
of reshape2. This works perfectly for getting the mean, sum, length, sd. But
when I want to calculate the median I get an error. I tried it with and
without removing

my_median <- function(x) median(x, na.rm = FALSE)
median_df <- dcast(patch_stats_dfm,formula=species~input+barriers,my_median)

Error in vapply(indices, fun, .default) : values must be type 'integer',
but FUN(X[[1]]) result is type 'double'

What does this error mean and what is causing the error, resp. how can I
solve the problem and
get a median?


    [[alternative HTML version deleted]]

R-help at r-project.org mailing list
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