Extracts the sentiment measures data.table in either wide (by default) or long format.

# S3 method for sento_measures
as.data.table(x, keep.rownames = FALSE, format = "wide", ...)

Arguments

x

a sento_measures object created using sento_measures.

keep.rownames

see as.data.table.

format

a single character vector, one of c("wide", "long").

...

not used.

Value

The panel of sentiment measures under sento_measures[["measures"]], in wide or long format.

Author

Samuel Borms

Examples

data("usnews", package = "sentometrics") data("list_lexicons", package = "sentometrics") data("list_valence_shifters", package = "sentometrics") sm <- sento_measures(sento_corpus(corpusdf = usnews[1:200, ]), sento_lexicons(list_lexicons["LM_en"]), ctr_agg(lag = 3)) data.table::as.data.table(sm)
#> date LM_en--wsj--equal_weight LM_en--wapo--equal_weight #> 1: 1995-01-04 0.000000000 -0.003129890 #> 2: 1995-01-05 0.006060606 -0.004950495 #> 3: 1995-01-06 0.006060606 -0.004950495 #> 4: 1995-01-07 0.006060606 -0.004950495 #> 5: 1995-01-08 0.000000000 0.004357298 #> --- #> 370: 1996-01-08 -0.005102041 -0.018939394 #> 371: 1996-01-09 -0.005102041 -0.021505376 #> 372: 1996-01-10 -0.005102041 -0.030089067 #> 373: 1996-01-11 0.000000000 -0.030089067 #> 374: 1996-01-12 0.000000000 -0.012002494 #> LM_en--economy--equal_weight LM_en--noneconomy--equal_weight #> 1: -0.003129890 0.0000000000 #> 2: 0.000000000 0.0005550555 #> 3: 0.000000000 0.0005550555 #> 4: 0.000000000 0.0005550555 #> 5: 0.000000000 0.0043572985 #> --- #> 370: 0.000000000 -0.0240414348 #> 371: 0.000000000 -0.0266074172 #> 372: 0.000000000 -0.0351911081 #> 373: 0.000000000 -0.0300890673 #> 374: -0.003418803 -0.0085836910
data.table::as.data.table(sm, format = "long")
#> date value lexicons features time #> 1: 1995-01-04 0.000000000 LM_en wsj equal_weight #> 2: 1995-01-04 -0.003129890 LM_en wapo equal_weight #> 3: 1995-01-04 -0.003129890 LM_en economy equal_weight #> 4: 1995-01-04 0.000000000 LM_en noneconomy equal_weight #> 5: 1995-01-05 0.006060606 LM_en wsj equal_weight #> --- #> 1492: 1996-01-11 -0.030089067 LM_en noneconomy equal_weight #> 1493: 1996-01-12 0.000000000 LM_en wsj equal_weight #> 1494: 1996-01-12 -0.012002494 LM_en wapo equal_weight #> 1495: 1996-01-12 -0.003418803 LM_en economy equal_weight #> 1496: 1996-01-12 -0.008583691 LM_en noneconomy equal_weight