Hi,
I noticed that if ?mean" or ?median in fun1 is changed to other functions, for
e.g. ?sum, it will show error message.
##Using shortened version that runs
library(plyr)
fun1 <- function(data, .group) {
f1 <- function(x) c(x, mean(x, na.rm = TRUE), sum(x, na.rm = TRUE))
res <- ddply(da
On 27-04-2014, at 11:01, Berend Hasselman wrote:
>
> On 27-04-2014, at 02:37, Nico Met wrote:
>
>> Dear all,
>>
>> I have a matrix (dimension, 16 x 12) where 2nd column represents class
>> (1,1,1,1,1,2,2,2, etc) information. I want to estimate average and median
>> values for each of the c
Hi,
You could also try:
library(plyr)
fun1 <- function(data, .group) {
f1 <- function(x) c(x, mean(x, na.rm = TRUE), median(x, na.rm = TRUE))
res <- ddply(data, .group, sapply, FUN = f1)
vec1 <- as.vector(table(res[, .group]))
indx <- sort(c(cumsum(vec1) - 1, cumsum(vec1)))
Un
On 27-04-2014, at 02:37, Nico Met wrote:
> Dear all,
>
>
>
> I have a matrix (dimension, 16 x 12) where 2nd column represents class
> (1,1,1,1,1,2,2,2, etc) information. I want to estimate average and median
> values for each of the class and add this information as a row at end of
> the ea
On Apr 26, 2014, at 5:37 PM, Nico Met wrote:
> Dear all,
>
>
>
> I have a matrix (dimension, 16 x 12) where 2nd column represents class
> (1,1,1,1,1,2,2,2, etc) information. I want to estimate average and median
> values for each of the class and add this information as a row at end of
> the
Hi,
Your dput() suggests dat as data.frame.
##Using the results you got,
res2 <- do.call(rbind,lapply(unique(dat$class),function(i) {x1
<-rbind(dat[dat$class==i,], avg[avg$class==i,], med[med$class==i,]);
rownames(x1)[!grepl("ara",rownames(x1))] <- paste0(c("Avg", "Med"), i); x1}))
A.K.
O
Dear all,
I have a matrix (dimension, 16 x 12) where 2nd column represents class
(1,1,1,1,1,2,2,2, etc) information. I want to estimate average and median
values for each of the class and add this information as a row at end of
the each classes.
for example:
dput(dat)
structure(list(class
7 matches
Mail list logo