[R] Error when using median as aggregation function in dcast
arun
smartpink111 at yahoo.com
Wed Jun 26 14:20:07 CEST 2013
Hi,
Please check this link:
http://stackoverflow.com/questions/4835202/error-with-custom-aggregate-function-for-a-cast-call-in-r-reshape2
A.K.
----- Original Message -----
From: Johannes Radinger <johannesradinger at gmail.com>
To: R help <r-help at r-project.org>
Cc:
Sent: Wednesday, June 26, 2013 4:36 AM
Subject: [R] Error when using median as aggregation function in dcast
Hi,
I am trying to calculated various summary statistics using the dcast
function
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
NAs:
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?
/Johannes
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
More information about the R-help
mailing list