Skip to content

Instantly share code, notes, and snippets.

@drmcarvalho
Last active June 29, 2017 12:33
Show Gist options
  • Save drmcarvalho/0270f52de36e16f53c93534e3f73299c to your computer and use it in GitHub Desktop.
Save drmcarvalho/0270f52de36e16f53c93534e3f73299c to your computer and use it in GitHub Desktop.
Este algoritmo gera a tabela de distribuição de frequência.
#Fonte: https://pt.stackoverflow.com/a/215885/27190
#Library library(dplyr) - carregar primeiro.
#Download do R: https://cran.r-project.org/bin/windows/base/
#Area que deseja atuar no futuro
# 1 -> Eng Comp, 2 -> Dev Web, 3 -> Designer, 4 -> Eng Soft, 5 -> Programacao
dados <- sort(c(1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5))
#O argumento Freq eh o Fi
tabela <- data.frame(t(table(dados)))[, -1]
tabela$dados <- as.numeric(levels(tabela$dados))
tabela <- tabela %>%
mutate(Fri = round((Freq / 21), 2),
FriPorCento = round((100 * Freq / sum(Freq)), 0),
Fac = cumsum(Freq),
Xi.Fi = dados * Freq)
tabela
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment