inst/doc/access_childes_db.R

## ----warning=FALSE, message=FALSE---------------------------------------------
# load the library
library(childesr)
library(dplyr)

## ----echo=FALSE, message=FALSE------------------------------------------------
# only run data-fetching chunks when off CRAN and the redivis client is
# available (CRAN machines should not make network requests)
can_eval <- requireNamespace("redivis", quietly = TRUE) &&
  identical(Sys.getenv("NOT_CRAN"), "true")
knitr::opts_chunk$set(echo = TRUE, message = FALSE, eval = can_eval)

## -----------------------------------------------------------------------------
# d_transcripts <- get_transcripts()
# head(d_transcripts)

## -----------------------------------------------------------------------------
# d_eng_na <- get_transcripts(collection = "Eng-NA")
# head(d_eng_na)

## -----------------------------------------------------------------------------
# # returns all transcripts in the brown corpus
# d_brown_transcripts <- get_transcripts(corpus = "Brown")
# # print the number of rows
# nrow(d_brown_transcripts)

## -----------------------------------------------------------------------------
# d_many_corpora <- get_transcripts(corpus = c("Brown", "Clark"))
# # print the number of rows
# nrow(d_many_corpora)

## -----------------------------------------------------------------------------
# d_shem <- get_transcripts(corpus = c("Brown", "Clark"),
#                           target_child = "Shem")
# # print the number of rows
# nrow(d_shem)

## -----------------------------------------------------------------------------
# d_participants <- get_participants()
# head(d_participants)

## -----------------------------------------------------------------------------
# d_target_child <- get_participants(role = "target_child")
# head(d_target_child)

## -----------------------------------------------------------------------------
# d_age_range <- get_participants(age = c(24, 36))
# head(d_age_range)

## -----------------------------------------------------------------------------
# d_adam_prod <- get_tokens(corpus = "Brown",
#                           role = "target_child",
#                           target_child = "Adam",
#                           token = c("dog", "ball"))
# 
# # view the structure of the data
# str(d_adam_prod)
# 
# # print the unique tokens
# unique(d_adam_prod$gloss)

## -----------------------------------------------------------------------------
# d_adam_types <- get_types(corpus = "Brown",
#                           target_child = "Adam",
#                           role = "target_child",
#                           type = c("dog", "ball"))
# 
# # print the number of times ball appears in the first transcript
# c(d_adam_types$gloss[1], d_adam_types$count[1])

## -----------------------------------------------------------------------------
# d_adam_utts <- get_utterances(corpus = "Brown",
#                               target_child = "Adam")
# 
# # view the structure of the data
# str(d_adam_utts)
# 
# # print the first five utterances
# d_adam_utts$gloss[1:5]

## -----------------------------------------------------------------------------
# d_adam_stats <- get_speaker_statistics(corpus = "Brown",
#                                        target_child = "Adam",
#                                        role = "target_child")
# 
# # get the average mlu across all Adam's transcripts
# if (!is.null(d_adam_stats)) mean(d_adam_stats$mlu_w)

## -----------------------------------------------------------------------------
# d_na_dog <- get_sql_query("SELECT corpus_name, COUNT(id) AS count FROM token WHERE collection_name = 'Eng-NA' AND gloss = 'dog' GROUP BY corpus_name")
# 
# # (the getters return NULL, with a message, if the database is unreachable)
# if (!is.null(d_na_dog)) dplyr::arrange(d_na_dog, desc(count))
# 

Try the childesr package in your browser

Any scripts or data that you put into this service are public.

childesr documentation built on Sept. 16, 2026, 9:09 a.m.