Language visualizations

if (!('home_visit_df' %in% ls())) {
  targets::tar_load(home_visit_df, store="../_targets")
}

library(wordcloud)
## Loading required package: RColorBrewer
library(RColorBrewer)

Language exposure

df <- home_visit_df |>
  dplyr::mutate(language_child = stringr::str_replace_all(language_child, " ", "_"))
xtabs(formula = ~ child_sex + language_child, data = df)
##          language_child
## child_sex english english_spanish
##    female     250              54
##    male       221              73

MB-CDI

12-mo-old English speakers

eng_12 <-
  readr::read_csv(
    "../data/csv/home_visit/agg/mcdi_english_12_combined.csv",
    col_types = readr::cols(.default = 'c'),
    show_col_types = FALSE
  )

There are \(n=\) 186 participant records.

eng_12_long <- eng_12 |>
  tidyr::pivot_longer(cols = !(play_id | site_id | subject_number),
                        names_to = "word",
                        values_to = "understands_or_says")

#xtabs(~ word + understands_or_says, eng_12_long)
word_ct <- eng_12_long |>
  dplyr::filter(!is.na(understands_or_says)) |>
  dplyr::filter(understands_or_says == "understands") |>
  dplyr::count(word, sort = TRUE)

quant_25 <- round(n_12_eng*.25, 0)
# rcb_color_paired <- RColorBrewer::brewer.pal(12, 'Paired')
# wordcloud::wordcloud(words = word_ct$word, freq = word_ct$n, min.freq = quant_25, colors = rcb_color_paired)

mcdi_viz_wordcloud(word_ct, n_participants = dim(eng_12)[1], quantile = .40)

18-mo-old English speakers

eng_18 <-
  readr::read_csv(
    "../data/csv/home_visit/agg/mcdi_english_18_combined.csv",
    col_types = readr::cols(.default = 'c'),
    show_col_types = FALSE
  )

There are \(n=\) 170 participant records.

word_ct <- eng_18 |>
  tidyr::pivot_longer(cols = !(play_id | site_id | subject_number),
                        names_to = "word",
                        values_to = "says") |>
  dplyr::filter(!is.na(says)) |>
  dplyr::filter(says == TRUE) |>
  dplyr::count(word, sort = TRUE)

quant_25 <- round(n_18_eng*.25, 0)
#wordcloud::wordcloud(words = word_ct$word, freq = word_ct$n, min.freq = quant_25, colors = rcb_color_paired)
mcdi_viz_wordcloud(word_ct, n_participants = dim(eng_18)[1], quantile = .50)
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : mommy could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : woofwoof could not be fit on page. It will not be
## plotted.

24-mo-old English speakers

eng_24 <-
  readr::read_csv(
    "../data/csv/home_visit/agg/mcdi_english_24_combined.csv",
    col_types = readr::cols(.default = 'c'),
    show_col_types = FALSE
  )

There are \(n=\) 144 participant records.

word_ct <- eng_24 |>
  tidyr::pivot_longer(cols = !(play_id | site_id | subject_number),
                        names_to = "word",
                        values_to = "says") |>
  dplyr::filter(!is.na(says)) |>
  dplyr::filter(says == TRUE) |>
  dplyr::count(word, sort = TRUE)
mcdi_viz_wordcloud(word_ct, n_participants = dim(eng_24)[1], quantile = .60)
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : help could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : strawberry could not be fit on page. It will not
## be plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : trash could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : rain_1 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : kiss could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : please could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : dog could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : balloon could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : arm could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : cracker could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : cookie could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : tree could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : choochoo could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : thankyou could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : ear could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : walk could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : baby could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : woofwoof could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : foot could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : sun could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : tummy could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : duck could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : allgone could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : hair could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : hat could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : door could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : hand could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : butterfly could not be fit on page. It will not
## be plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : uhoh could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : truck could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : meow could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : shoe could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : off could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : star could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : down could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : baabaa could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : swing could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : frog could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : soap could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : sleep could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : wet_1 could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : two could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : quackquack could not be fit on page. It will not
## be plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : shh could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : banana could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : jump could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : vroom could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : cup could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : mouth could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : brush could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : moon could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : open could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : pants could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : cat could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : bear could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : apple could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : nightnight could not be fit on page. It will not
## be plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : up could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : ball could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : diaper could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : dirty could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : buttocks could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : blanket could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : sock could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : three could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : more could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : head could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : sit could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : no could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : bird could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : car could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : yumyum could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : eye could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(words = wd_ct$word, freq = wd_ct$n,
## min.freq = my_thresh, : ouch could not be fit on page. It will not be
## plotted.
rare_word_ct <- word_ct |>
  dplyr::filter(n < dim(eng_24)[1]*.25)
# 
# wordcloud::wordcloud(words = rare_word_ct$word, freq = rare_word_ct$n)
mcdi_viz_wordcloud(rare_word_ct, n_participants = dim(eng_24)[1], quantile = .25)
## No words meet criterion: n = 36 'know/say' out of n = 144 participants
## Try quantile < 0.24
## NULL