Skip to content

Instantly share code, notes, and snippets.

@beatrizmilz
Last active March 24, 2021 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beatrizmilz/50a683db77c1e6e216286bc60c12afa3 to your computer and use it in GitHub Desktop.
Save beatrizmilz/50a683db77c1e6e216286bc60c12afa3 to your computer and use it in GitHub Desktop.
# Código para realizar o sorteio!
# Carregar o pipe
library(magrittr, include.only = "%>%")
# Endereço da planilha gerada pelo Google Forms
url <- "https://docs.google.com/spreadsheets/d/1B4VPVsBsJYHVGlXJpKGs-p6fZj7pu-Vlnofpibg1RLc/edit?usp=sharing"
# Lê as respostas.
# Apenas quem tem acesso a este arquivo vai conseguir fazer essa etapa.
# É necessário autenticar!
respostas <- googlesheets4::read_sheet(url)
# Seleciona as 3 primeiras colunas,
# limpa os nomes, remove os NAs,
# e obtém apenas os valores distintos (evitar nomes repetidos)
nomes_participando <- respostas %>%
dplyr::select(1:3) %>%
janitor::clean_names() %>%
tidyr::drop_na(qual_e_o_seu_nome, qual_e_o_seu_email) %>%
dplyr::distinct(qual_e_o_seu_nome, qual_e_o_seu_email)
# Sorteia nomes!
nomes_participando %>%
dplyr::sample_n(2, replace = FALSE)
# Pessoas sorteadas:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment