plotScot: Plots Counts of Documents or Words over Time (relative to...

Description Usage Arguments Details Value Examples

View source: R/plotScot.R

Description

Creates a plot of the counts/proportion of documents/words in the subcorpus, which could be specified by id.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
plotScot(
  object,
  id = object$meta$id,
  type = c("docs", "words"),
  rel = FALSE,
  mark = TRUE,
  unit = "month",
  curves = c("exact", "smooth", "both"),
  smooth = 0.05,
  main,
  xlab,
  ylab,
  ylim,
  both.lwd,
  both.col,
  both.lty,
  natozero = TRUE,
  file,
  ...
)

Arguments

object

textmeta object with strictly tokenized text component vectors if type = "words"

id

Character: Vector (default: object$meta$id) which IDs specify the subcorpus

type

Character: Should counts/proportion of documents "docs" (default) or words "words" be plotted?

rel

Logical: Should counts (default: FALSE) or proportion (TRUE) be plotted?

mark

Logical: Should years be marked by vertical lines (default: TRUE)?

unit

Character: To which unit should dates be floored (default: "month"). Other possible units are "bimonth", "quarter", "season", "halfyear", "year", for more units see round_date.

curves

Character: Should "exact", "smooth" curve or "both" be plotted (default: "exact")?

smooth

Numeric: Smoothing parameter which is handed over to lowess as f (default: 0.05).

main

Character: Graphical parameter

xlab

Character: Graphical parameter

ylab

Character: Graphical parameter

ylim

Graphical parameter (default if rel = TRUE: c(0, 1))

both.lwd

Graphical parameter for smoothed values if curves = "both"

both.col

Graphical parameter for smoothed values if curves = "both"

both.lty

Graphical parameter for smoothed values if curves = "both"

natozero

Logical: Should NAs be coerced to zeros (default: TRUE)? Only has an effect if rel = TRUE.

file

Character: File path if a pdf should be created.

...

additional graphical parameters

Details

object needs a textmeta object with strictly tokenized text component (character vectors) if you use type = "words". If you use type = "docs" you can use a tokenized or a non-tokenized text component. In fact, you can use the textmeta constructor (textmeta(meta = <your-meta-data.frame>)) to create a textmeta object containing only the meta field and plot the resulting object. This way you can save time and memory at the first glance.

Value

A plot Invisible: A dataframe with columns date and counts, respectively proportion

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
data(politics)
poliClean <- cleanTexts(politics)

# complete corpus
plotScot(object=poliClean)

# subcorpus
subID <- filterWord(poliClean, search=c("bush", "obama"), out="bin")
plotScot(object=poliClean, id=names(subID)[subID], curves="both", smooth=0.3)

## End(Not run)

tosca documentation built on Oct. 28, 2021, 5:07 p.m.