Created
December 2, 2015 15:34
-
-
Save syu-id/c26c3a970655a805b82f to your computer and use it in GitHub Desktop.
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
library(dplyr) | |
tokens <- read.csv('data/tokens.csv') | |
result <- tokens %>% | |
group_by(native, id) %>% | |
summarise( | |
n_token = length(token), | |
n_type = length(unique(token)), | |
ttr = n_type / n_token, | |
gi = n_type / sqrt(n_token) | |
) | |
# save the result to csv | |
write.csv(result, file = 'out/2015.11.27-ttr_gi.csv', row.names = FALSE) | |
# print out the result | |
result %>% | |
mutate_each( | |
funs(round(., 3)), | |
ttr:gi | |
) %>% | |
as.data.frame() %>% | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment