Packages
library(tidyverse)
library(wordbankr)
Error in library(wordbankr): there is no package called 'wordbankr'
library(here)
my_sounds <- c("meow", "woof woof", "cockadoodledoo")
# first get the items in the animal category
sounds <- get_item_data(language = "English (American)",
form = "WG") %>%
filter(definition %in% my_sounds)
Error in get_item_data(language = "English (American)", form = "WG"): could not find function "get_item_data"
# then get instrument data for those items
sounds_data <- get_instrument_data(
language = "English (American)",
form = "WG",
items = sounds$item_id,
administrations = TRUE,
iteminfo = TRUE
) %>%
mutate(produces = value == "produces",
understands = case_when(
produces == TRUE | value == "understands" ~ TRUE,
TRUE ~ FALSE
)) %>%
drop_na(produces) %>%
rename(sound = uni_lemma)
Error in get_instrument_data(language = "English (American)", form = "WG", : could not find function "get_instrument_data"
# what proportion of kids at each age understand/produce each word?
sounds_summary <- sounds_data %>%
group_by(age, sound) %>%
summarise(kids_produce = sum(produces, na.rm = TRUE),
kids_understand = sum(understands, na.rm = TRUE),
kids_respond = n_distinct(data_id),
prop_produce = kids_produce / kids_respond,
prop_understand = kids_understand / kids_respond)
Error in eval(expr, envir, enclos): object 'sounds_data' not found
Now let’s export both data frames for the lab.
write_csv(sounds_data, here::here("data",
"animal_sounds_data.csv"))
Error in eval(expr, envir, enclos): object 'sounds_data' not found
write_csv(sounds_summary, here::here("data",
"animal_sounds_summary.csv"))
Error in eval(expr, envir, enclos): object 'sounds_summary' not found
LS0tCnRpdGxlOiAiTGFiIDAzYTogQW5pbWFsIFdvcmQgQ2xlYW5pbmciCnN1YnRpdGxlOiAiQk1JIDUvNjI1IgphdXRob3I6ICJBbGlzb24gSGlsbCIKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6CiAgICB0aGVtZTogZmxhdGx5CiAgICBjb2RlX2Rvd25sb2FkOiB0cnVlCi0tLQoKYGBge3Igc2V0dXAsIGluY2x1ZGUgPSBGQUxTRSwgY2FjaGUgPSBGQUxTRX0Ka25pdHI6Om9wdHNfY2h1bmskc2V0KGVycm9yID0gVFJVRSwgY29tbWVudCA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