juliasilge / tidytext

Text mining using tidy tools :sparkles::page_facing_up::sparkles:

Home Page:https://juliasilge.github.io/tidytext/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in cast_dfm() function

oguzozbay opened this issue · comments

Dear Julia.
I am trying to create a DocumentTermMatrix with tidytext’s cast_dtm.
And I used my code 2 moths ago. It was OK. It worked.
But now, it does not work, and I got an error.
I searced in internet but could not find a solution.

tidy_M <- M %>% unnest_tokens(output= word, input= STM_text_16_02_2023, token = "words")
I will create document feature matrix (library(tidytext)):
M_dfm <- tidy_M %>% count(UT, word) %>% cast_dfm(UT, word, n)

I GOT BELOW ERROR:
Error in if (...length() && any(...names() == "Dimnames")) .Object@Dimnames <- fixupDN(.Object@Dimnames) : missing value where TRUE/FALSE needed

I checked that there is no NA in my data:
any(is.na(tidy_M)) # [1] FALSE

########################
Below is an example of my data:

head( tidy_M)
UT publication_year Cluster word
1 WOS:000232003500109 2005 8 computation
2 WOS:000232003500109 2005 8 acceleration
3 WOS:000232003500109 2005 8 measurement
4 WOS:000232003500109 2005 8 inertial_measurement
5 WOS:000232003500109 2005 8 unit
6 WOS:000232003500109 2005 8 inertial
#########################
Best regards.

I updated R. Now it seem OK

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.