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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 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.
Remember that you can find out the data type of any R object using the class function. E.g. class(n.time.v)
- 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.
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.
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.
Using i is a matter of convention. You could name this variable anything that you wish: e.g. my.int, x, etc.
- 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
Rights 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
DOI: https://doi.org/10.1007/978-3-319-03164-4_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-03163-7
Online ISBN: 978-3-319-03164-4
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)