How to add docvars to a corpus from another data frame object in r

430 Views Asked by At

I started using R very recently and this is my first post here. I'm still trying to get the hang of things.

Problem: I have a text corpus (corpus1) created to do text analytics using quanteda (primarily). I've also created a docvar (filename) in the corpus which is a common variable for a separate dataframe (df1) I had previously created. I now want to add some (or all) of the variables from the dataframe (df1) to the corpus (corpus1). Note that the filename is unique and common in both dataframe (df1) and (corpus1).

I have tried to use the docvar command but without any success

docvars(corpus1, "file") <- df1

also,

corpus1 <- corpus(txt1(which is a list of the text file), docvars = df1)

My goal is to have the column variables from the dataframe (df1) as docvars in the text corpus (corpus1) which I will need for future analyses.

Thanks in advance for any suggestions and help.

0

There are 0 best solutions below