as.zoo: Generate Time Series Object From Topicmodel.

Description Usage Arguments Details Examples

Description

For each document, the k top topics are evaluated.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
as.zoo(x, ...)

## S4 method for signature 'LDA'
as.zoo(
  x,
  k = 3L,
  regex = "^.*?(\\d{4}-\\d{2}-\\d{2}).*?$",
  select = NULL,
  aggregation = NULL
)

Arguments

x

A topicmodel inheriting from class LDA.

...

Further arguments.

k

An integer value, the number of top topics evaluated.

regex

Regular expression to extract the date from the document name, defaults to match pattern YYYY-MM-DD.

select

An integer vector, topics to select.

aggregation

Either "year", "quarter" or "month", if NULL, no aggregation is performed.

Details

The document names of the LDA object are assumed to include a date that can be extracted by using a regular expression (argument regex). If argument select is NULL, the time series is prepared for all topics. If select is a length-one integer value, the time series is reported only for single topic. If select is a length-two integer vector, the dispersion of the co-occurrence of the two topics across time is returned.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data(BE_lda, BE_labels)

# The document names are assumed to include a date that can be 
# extracted and parsed
head(BE_lda@documents)

# Get time series for all topics
z <- as.zoo(BE_lda, k = 3L, aggregation = "year")
dim(z)
colnames(z) <- BE_labels
plot(z[,grep("Asyl", BE_labels)]) # subsequent subsetting

# Get time series for a single topic
z <- as.zoo(BE_lda, k = 3L, aggregation = "year", select = grep("Asyl", BE_labels))
plot(z)

# Get time series for the co-occurrence of two topics
z <- as.zoo(BE_lda, k = 3L, select = c(28L, 203L), aggregation = "month")
z <- as.zoo(
  BE_lda, k = 3L,
  select = c(
    grep("Asyl", BE_labels),
    grep("Integration", BE_labels)
  )
)

PolMine/polmineR.topics documentation built on March 6, 2020, 6:03 p.m.