Created
June 27, 2018 08:29
-
-
Save ndricca/95dca0530e4a1be6ab5be52b7753e8a5 to your computer and use it in GitHub Desktop.
dplyr conteggio e proporzione in riga per grouppi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm(list = ls()) | |
library(dplyr) | |
df <- data_frame(y = rnorm(10,2), | |
x1 = as.factor(rbinom(10,1,0.5)), | |
x2 = as.factor(rep(letters[1:2],5))) | |
df | |
df %>% | |
add_count() %>% | |
add_count(x1) %>% | |
mutate(prop = nn/n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment