0

I have a simple dataframe with the following column name

Subject # Type #  Value0 # value1# value2# ....value100

I want to use the dplyr summarize operation in order to get the mean of each value columns. I think there is a useful alternative to

ddply(dataframe, c("Subject,Type"), summarize, m1= mean(value1), m2=mean(value2)....)

If I gather all Value column name in a list

names =c("Value0,Value1,....Value100) 

How can I use this list in ddply?

Irshad
  • 3,071
  • 5
  • 30
  • 51
fableb
  • 71
  • 3
  • 5

1 Answers1

0

We can use summarise_each

library(dplyr)
df1 %>%
     group_by(Subject, Type) %>%
     summarise_each(funs(mean= mean(., na.rm=TRUE)))
akrun
  • 874,273
  • 37
  • 540
  • 662