'Is saving docvars for kwic dfs possible?

Is there a way to save docvars to kwic output dataframe? I would like to save docvars such as dates and title of documents. I've read this https://github.com/quanteda/quanteda/issues/649 but can't understand if there was a change in the end.

I would like to later use the words surrounding my keyword to run other text analyses such as stm and tf_idf using group variables.



Solution 1:[1]

I have done this manually, see example below:

docvars_df <- docvars(toks.full)
docvars_df$docname <- paste("text", 1:nrow(docvars_df), sep = "")

# attaching docvars:
kwic_df <- merge(kwic_df, docvars_df, by = "docname")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rnewbie