Learn R Programming

polmineR (version 0.7.0)

count: Get counts.

Description

Count number of occurrences of a query (CQP syntax may be used) or, if query is NULL (default), of all tokens.

Usage

count(.Object, ...)
"count"(.Object, query = NULL, cqp = is.cqp, id2str = TRUE, pAttribute = getOption("polmineR.pAttribute"), mc = getOption("polmineR.cores"), verbose = TRUE, progress = FALSE)
"count"(.Object, query, pAttribute = NULL, freq = FALSE, total = T, mc = F, progress = T, verbose = FALSE)
"count"(.Object, query = NULL, pAttribute = getOption("polmineR.pAttribute"), verbose = TRUE)
"count"(.Object, corpus, pAttribute)

Arguments

.Object
a "partition" or "partitionBundle" object, or a character vector (length 1) providing the name of a corpus
...
further parameters
query
a character vector (one or multiple terms to be looked up), CQP syntax can be used.
cqp
either logical (TRUE if query is a CQP query), or a function to check whether query is a CQP query or not (defaults to is.query auxiliary function)
id2str
logical, whether to add rownames (only if query is NULL)
pAttribute
the p-attribute(s) to use
mc
logical, whether to use multicore (defaults to FALSE)
verbose
logical, whether to be verbose
progress
logical, whether to show progress
freq
logical, if FALSE, counts will be reported, if TRUE, frequencies
total
defaults to FALSE, if TRUE, the added value of counts (column: TOTAL) will be amended to the data.table that is returned
corpus
name of CWB corpus

Value

a "data.table"

See Also

For a metadata-based breakdown of counts (i.e. a differentiation by s-attributes), see "dispersion".

count

Examples

Run this code
## Not run: 
# \dontrun{
#   use("polmineR.sampleCorpus")
#   debates <- partition("PLPRBTTXT", list(text_id=".*"), regex=TRUE)
#   x <- count(debates, "Arbeit") # get frequencies for one token
#   x <- count(debates, c("Arbeit", "Freizeit", "Zukunft")) # get frequencies for multiple tokens
#   x <- count("PLPRBTTXT", c("Migration", "Integration"), "word")
# 
#   debates <- partitionBundle(
#     .Object="PLPRBTTXT",
#     def=list(text_date=sAttributes("PLPRBTTXT", "text_date")),
#     regex=TRUE, mc=FALSE, verbose=FALSE
#   )
#   aiu <- count(debates, c("Arbeit", "Integration", "Umwelt"))
# }
# ## End(Not run)

Run the code above in your browser using DataLab