The childesr package allows you to access data in the
childes-db from R. This removes the need to write complex SQL queries in
order to get the information you want from the database. This vignette
shows some examples of how to use the data loading functions and what
the resulting data look like.
There are several different get_ functions that you can
use to extract different types of data from the childes-db:
get_transcripts()get_participants()get_tokens()get_types()get_utterances()get_speaker_statistics()get_sql_query()Technical note 1: As of childesr 0.3, data are
retrieved from the versioned childes-db
dataset on Redivis (using the redivis
R package) rather than from a MySQL server, so no database connection is
needed. Install the redivis client with
install.packages("redivis", repos = "https://langcog.r-universe.dev").
(A bug in redivis macOS binaries built before 2026-07-31 broke OAuth
token caching, causing repeated browser authentication prompts; current
r-universe binaries are fine — if you see repeated auth prompts, update
the redivis package.) The dataset is public, so no Redivis account is
required; for headless or scripted use you can authenticate with an API
token — created under your workspace settings at redivis.com and set via
Sys.setenv(REDIVIS_API_TOKEN = "...") — which bypasses the
OAuth cache entirely. The connection argument of the
get_ functions and the connect_to_childes() /
clear_connections() functions are deprecated and retained
only for backwards compatibility.
Technical note 2: We have tried to optimize the time it takes to get data from the database. But if you try to query and get all of the tokens, it will take a long time.
Numeric ids in these tables (transcript_id,
utterance_id, token id, and so on) are
internal to a given database release: they are not stable across
versions of childes-db, and never will be. For reproducible analyses,
always pin the database version with the db_version
argument (e.g. get_transcripts(db_version = "2021.1")). To
link transcripts across database versions — or to the wider set of
TalkBank tools — use the TalkBank persistent identifier in the
pid column returned by get_transcripts().
The get_transcripts function returns high-level
information about the transcripts that are available in the database.
You can filter your query to get the transcripts for a specific
collection, corpus, or child.
For example, you can run get_transcripts without any
arguments to return all of the transcripts in the database.
If you only want information about a specific collection, such as the English-American transcripts, then you can specify this in the collection argument.
If you know the corpus that you want to analyze, then you can specify this in the corpus argument. The following function call will return information about all of the transcripts in the Brown corpus.
# returns all transcripts in the brown corpus
d_brown_transcripts <- get_transcripts(corpus = "Brown")
# print the number of rows
nrow(d_brown_transcripts)If you want more than one corpus, then you can pass a multiple corpus names. You can also pass more than one name to the collections and child arguments.
d_many_corpora <- get_transcripts(corpus = c("Brown", "Clark"))
# print the number of rows
nrow(d_many_corpora)If you want transcript information about a specific child from a corpus, then you pass their name to the child argument. Note that the following function call will not return any of the transcripts from the Brown corpus because the child Shem is not present in that corpus.
The get_participants function returns background
information about the speakers (both the children and the adults) in the
database. This includes information about:
Again, if you run the function with no arguments, then you get all the background information for all speakers in the database.
The participants function introduces three new arguments: role, age, and sex. The role argument allows you to get information about a specific kind of speaker, such as the “target_child.”
The age argument takes a number indicating the age(s) of children (in months) that you want to analyze. you can use this argument in two ways
For example, you can get the participant information for all of the children who had transcripts between the ages of 24 and 36 months.
The get_tokens function returns a table with a row for
each token based on a set of filtering criteria. The token argument
allows you to pass a vector of one or more tokens that you want to
analyze.
For example, if you wanted to get all of the production data for a specific token(s), then you could run the following call to get all instances of “dog” and “ball” for Adam in the Brown corpus.
The get_types() function works like the
get_tokens() function, returning a table with a row for
each type based on set of filtering criteria. The type argument allows
you to pass a vector of one or more types that you want to analyze. The
main difference is that you now have a single row for each type (i.e., a
concept) and a variable count that tracks the number of
times that type appeared in a particular transcript.
For example, if you wanted to get all of the production data for a specific type(s), then you could run the following call to get counts of “dog” and “ball” for all of Adam’s transcripts in the Brown corpus.
The get_utterances function returns a table with a row
for each utterance based on user-defined filtering criteria. For
example, the following function will get you all of the utterances in
the Brown Corpus for the child Adam.
The get_speaker_statistics() function returns a table
with a row for each transcript and columns that contain a set of summary
statistics for that transcript. The summary statistics include:
num_utterances)num_types)num_tokens)num_morphemes)mlu_w)mlu_m)For example, if we wanted to get the summary statistics for Adam’s production data, we could run the following call.
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)The get_sql_query() function returns a table from a SQL
query run on the specified database version. As of childesr 0.3, queries
run on Redivis’s query engine, which uses BigQuery
Standard SQL rather than MySQL’s dialect. For example, if you wanted
to see the top 10 corpora in the Eng-NA collection with the
highest count of token for “dog”, you could run the following call.