I am facing an issue with multidplyr's partition function. My objective is to find the summary statistics by group of column names. ex:
rcols <- c("cyl","am","vs")
Now I wanted to find summary statistics by using above rcols object. I can do it in dplyr by using following lines.
df <- mtcars %>% group_by(.dots=rcols) %>% summarise(Mean=mean(mpg))
Now I wanted to do the same by using multidplyr package.
df <- mtcars %>% partition(rcols) %>% summarise(Mean=mean(mpg)) %>% collect()
But the above line is not working as expected.
Can anyone help me on this issue?
Thanks in advance.
We have to create a text with the required query.
library(dplyr)
library(multidplyr)
rcols <- c("cyl","am","vs")
k1<-paste("d1<-mtcars%>%partition(",paste(rcols,collapse=","),")%>%summarise(Mean=mean(mpg))%>%collect()",sep="")
k2<-eval(parse(text=k1))