Learn R Programming

birdnik (version 0.1.1)

word_frequency: Count the per-year frequency of words

Description

word_frequency provides, for a vector of words, the number of appearances each word made per year in the source texts Wordnik uses.

Usage

word_frequency(key, words, use_canonical = FALSE, start_year = 1800,
  end_year = 2012, ...)

Arguments

key

a Wordnik API key. These can be obtained at the Wordnik developer portal.

words

a vector of words.

use_canonical

whether to use the stemmed, canonical form of the word (i.e. 'cat', for 'cats') instead of the actual word. FALSE by default. Note that for pronunciations specifically, setting it to TRUE may get a wider range of pronunciations; you should experiment.

start_year

the earliest year to get frequencies for. 1800 (the earliest accepted value) by default.

end_year

the latest year to get frequencies for. 2012 (the latest accepted value) by default.

...

further arguments to pass to httr's GET.

Value

a data.frame of 3 columns; word, year and frequency.

Examples

Run this code
# NOT RUN {
cats_versus_dogs <- word_frequency(key = "notarealkey", words = c("cat", "dog"))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab