juliasilge / juliasilge.com

My blog, built with blogdown and Hugo :link:
https://juliasilge.com/
40 stars 27 forks source link

Word associations from the Small World of Words | Julia Silge #18

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Word associations from the Small World of Words | Julia Silge

Do you subscribe to the Data is Plural newsletter from Jeremy Singer-Vine? You probably should, because it is a treasure trove of interesting datasets arriving in your email inbox. In the November 28 edition, Jeremy linked to the Small World of Words project, and I was entranced.

https://juliasilge.com/blog/word-associations/

ghost commented 3 years ago

Thank you so much for this lovely guide, Julia! I thoroughly enjoyed reading it! I tried replicating your wonders on my mac, but somehow I couldn't get it to work when it came to your "money" plot. Do you have an idea as to what might have gone wrong with this code bit: " Error: object 'models' not found Run rlang::last_error() to see where the error occurred. In addition: Warning message: All elements of ... must be named. Did you want data = c(age, n, age_total, percent)? "

In any case, thank you for sharing this fun project! 😊

juliasilge commented 3 years ago

@sebsebar Did you try updating to the newer interface for nest() with nest(data = c(age, n, age_total, percent))? That may fix the problem.

ghost commented 3 years ago

It leaves me a new error 😅 "Error: object 'models' not found"

juliasilge commented 3 years ago

I would take a look at the previous chunks and make sure everything looks the same in terms of columns, results, etc. I just re-downloaded the data set and this works for me still:

swow_freq %>%
    nest(data = c(age, n, age_total, percent)) %>%
    mutate(models = map(data, ~ glm(cbind(n, age_total) ~ age, ., 
                                    family = "binomial")))
# A tibble: 57 x 3
   to       data                  models
   <chr>    <list>                <list>
 1 bank     <tibble[,4] [13 × 4]> <glm> 
 2 banks    <tibble[,4] [13 × 4]> <glm> 
 3 bills    <tibble[,4] [13 × 4]> <glm> 
 4 business <tibble[,4] [13 × 4]> <glm> 
 5 buy      <tibble[,4] [13 × 4]> <glm> 
 6 car      <tibble[,4] [13 × 4]> <glm> 
 7 cash     <tibble[,4] [13 × 4]> <glm> 
 8 change   <tibble[,4] [13 × 4]> <glm> 
 9 charity  <tibble[,4] [13 × 4]> <glm> 
10 cheap    <tibble[,4] [13 × 4]> <glm> 
# … with 47 more rows