search for: x4m

Displaying 3 results from an estimated 3 matches for "x4m".

Did you mean: 64m
2017 Sep 09
2
Avoid duplication in dplyr::summarise
...fails. df <- data.frame(matrix(rnorm(40), 10, 4), f1 = gl(3, 10, labels = letters[1:3]), f2 = gl(3, 10, labels = letters[4:6])) df %>% group_by(f1, f2) %>% summarise(x1m = mean(X1), x2m = mean(X2), x3m = mean(X3), x4m = mean(X4)) df %>% group_by(f1) %>% summarise(x1m = mean(X1), x2m = mean(X2), x3m = mean(X3), x4m = mean(X4)) # My fail attempt s <- function() { dplyr::summarise(x1m = mean(X1), x2m = mean(X2), x3m = mean(X...
2017 Sep 09
1
Avoid duplication in dplyr::summarise
...hieve what you want with a slight modification of your definition of s(), using the hint from the error message that you need an argument '.': s <- function(.) { dplyr::summarise(., x1m = mean(X1), x2m = mean(X2), x3m = mean(X3), x4m = mean(X4)) } 2. You have not given a great test case in how you set your two factors because the two group_by()'s will give the identical groupings, An alternative which confirms that the function s() does what you want might be: df <- data.frame(matrix(rnorm(40), 10, 4),...
2017 Sep 09
0
Avoid duplication in dplyr::summarise
..., 4), > f1 = gl(3, 10, labels = letters[1:3]), > f2 = gl(3, 10, labels = letters[4:6])) > > > df %>% > group_by(f1, f2) %>% > summarise(x1m = mean(X1), > x2m = mean(X2), > x3m = mean(X3), > x4m = mean(X4)) > > df %>% > group_by(f1) %>% > summarise(x1m = mean(X1), > x2m = mean(X2), > x3m = mean(X3), > x4m = mean(X4)) > > # My fail attempt > > s <- function() { > dplyr::summarise(x1m = mean(X1), >...