Skip to main content

Token Distribution Analysis

  • Chapter
  • First Online:
Text Analysis with R for Students of Literature

Abstract

This chapter explains how to use the positions of words in a vector to create distribution plots showing where words occur across a narrative. Several important R functions are introduced including seq_along, rep, grep, rbind, apply, and do.call. if conditionals and for loops are also presented.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 49.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 64.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    For some very interesting work on modeling narrative time, see Mani, Inderjeet. The Imagined Moment: Time, Narrative and Computation. University of Nebraska Press, 2010.

  2. 2.

    Remember that you can find out the data type of any R object using the class function. E.g. class(n.time.v)

  3. 3.

    If you get an error saying: “Error in plot.new(): figure margins too large” you may not have enough screen real estate devoted to the plot pane of RStudio. You can solve this problem by increasing the size of the plots pane (just click and drag the frame). Your plot may also appear a lot taller (or thicker) than the one seen here. I have shrunk the plotting pane height in RStudio to make the image fit this page better.

  4. 4.

    If you are using RStudio, you can simply check the environment window pane. After running rm(list = ls()) or clearing the workspace from the session menu, it will be blank.

  5. 5.

    Do not be alarmed if you see a series of backslash characters in the text. These are escape characters that R adds before quotation marks and apostrophes so that they will not be treated as special characters and parsed by R.

  6. 6.

    Using i is a matter of convention. You could name this variable anything that you wish: e.g. my.int, x, etc.

  7. 7.

    It might seem a bit odd, but in R even objects containing only one item are vectors. So in this example the y object is a vector of one item. If you simply enter y into the console, you’ll get a bracketed number 1 [1] followed by the value 2, which is the value held in the first position of the y vector.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer International Publishing Switzerland

About this chapter

Cite this chapter

Jockers, M.L. (2014). Token Distribution Analysis. In: Text Analysis with R for Students of Literature. Quantitative Methods in the Humanities and Social Sciences. Springer, Cham. https://doi.org/10.1007/978-3-319-03164-4_4

Download citation

Publish with us

Policies and ethics