Created
December 11, 2019 18:11
-
-
Save hepplerj/1c1000e25b297a429b8e612aeda908fe to your computer and use it in GitHub Desktop.
Turn a frequency table into a list of individual items
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(tidyverse) | |
library(readxl) | |
data <- readxl::read_xlsx("data.xlsx") | |
reshaped <- data %>% gather(word, freq, 2:21) | |
reshaped <- reshaped %>% drop_na() | |
cleaned <- reshaped %>% | |
uncount(freq) | |
names(cleaned) <- c("noun","color") | |
write_csv(cleaned, "tidy.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment