Search code examples
rtextcorpusquanteda

How do I attach metadata to a text corpus with quanteda?


I am using quanteda to create a text corpus and trying to attach metadata, but I keep getting an error. I have used this code before on another dataset, but for some reason it's not working with my current dataset. The code is:

dfm.ineq1 <- corpus(df.ineq$speech, 
                        docnames=df.ineq$speechID, 
                        docvars=select(party))

The error I get is:

Error in select_(.data, .dots = lazyeval::lazy_dots(...)) : object 'party' not found

I also tried to put party in quotes and got this error:

Error in UseMethod("select_") : no applicable method for 'select_' applied to an object of class "character"

The party column is pretty straight forward. The values are:

"Democratic"  "Republican"  "N/A"         "Independent"

Any ideas on what might be going wrong?


Solution

  • I realized I forgot to put the dataframe in the select parenthesis!

    dfm.ineq1 <- corpus(df.ineq$speech, 
                            docnames=df.ineq$speechID, 
                            docvars=select(df.ineq, party))