S4 class to organize counts. The classes polmineR and
ngrams inherit from the class.
# S4 method for count summary(object) # S4 method for count length(x) # S4 method for count hist(x, ...)
| object | A |
|---|---|
| x | A |
| ... | Further parameters. |
The summary-method in combination with a weighed
count-object can be used to perform a dictionary-based sentiment
analysis (see examples).
The length-method is synonymous with the size-method
and will return the size of the corpus or partition a count
has been derived from.
statObject of class data.table.
corpusObject of class character the CWB corpus the partition is based on .
encodingObject of class character, the encoding of the corpus.
nameObject of class character, a name for the object.
sizeObject of class integer, the size of the partition or
corpus the count is based upon.
The count-class inherits from the textstat-class
Andreas Blaette
# sample for dictionary-based sentiment analysis weights <- data.table::data.table( word = c("gut", "super", "herrlich", "schlecht", "grob", "mies"), weight = c(1,1,1,-1,-1,-1) ) corp <- corpus("GERMAPARLMINI") sc <- subset(corp, date == "2009-11-11") cnt <- count(sc, p_attribute = "word") cnt <- weigh(cnt, with = weights) y <- summary(cnt) # old, partition-based workflow p <- partition("GERMAPARLMINI", date = "2009-11-11")#>#>#>weights <- data.table::data.table( word = c("gut", "super", "herrlich", "schlecht", "grob", "mies"), weight = c(1,1,1,-1,-1,-1) ) p <- weigh(p, with = weights) summary(p)#> $name #> [1] "" #> #> $size #> [1] 117614 #> #> $p_attribute #> [1] "word" #> #> $unique #> [1] 12080 #> #> $positive_n #> [1] 87 #> #> $positive_share #> [1] 0.0007397079 #> #> $positive_weighed #> [1] 87 #> #> $negative_n #> [1] 7 #> #> $negative_share #> [1] 5.951672e-05 #> #> $negative_weighed #> [1] -7 #>