I'm having some issues with converting a dataframe to use with the tidytext
function unnest_tokens
The error is: error in UseMethod("unnest_tokens_") : no applicable method for 'unnest_tokens_' applied to an object of class "character"
From this:
notesWords <- text_df %>%
unnest_tokens(word, text) %>%
count(segment, word, sort = TRUE) %>%
ungroup()
I'm not sure what the error is telling me, because when I check the type of my input text_df
, I get chr [1:6067]
However, because I'm looking at the inputs to a document, I need to input characters, so I'm not sure how to solve this error if it is telling characters should not be inputted. Should I convert the characters to something else?
Thanks,
* UPDATED *
Here is how text_df
is created: data.frame(textData['notes'])
The contents of text_df
are:
head(text_df)
notes
1 foo
2 bar
3 baz
And str(text_df)
'data.frame': 6067 obs. of 1 variable:
$ notes: chr "foo" "bar" "baz" ...
However when I use use the data frame now, the error becomes:
Input must be a character vector of any length or a list of character vectors, each of which has a length of 1.