Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility Issue with docnames Function in corpus and tokens dfm Objects #2282

Open
oushiei120 opened this issue May 30, 2023 · 4 comments

Comments

@oushiei120
Copy link

I used to be able to use the docnames function on corpus and tokens dfm objects in the quanteda package. However, it seems that I am no longer able to do so. Previously, after using the readtext function to read files, I would directly assign the file names to the tokens object as docvar1 or docvar2. Now, I am facing an issue with this approach and I am seeking a solution.

corpus_six <- readtext("",
                       docvarsfrom = "filenames") %>% corpus()
token_faster <- tokenize_fasterword(corpus_six)

token_select <- token_faster %>% 
  tokens(remove_punct = TRUE, remove_numbers = TRUE) 

docnames(token_select) <- docnames(corpus_six)
docvars(token_select, "author") <- docvars(corpus_six, "docvar1")
docnames(token_select) <- docvar(token_select, "author")

and I run this code but :

> docnames(token_select) <- docnames(corpus_six)
Error in UseMethod("docnames") : 
  no applicable method for 'docnames' applied to an object of class "c('corpus', 'character')"
@oushiei120
Copy link
Author

The tutorial is not clear:https://quanteda.io/reference/docnames.html

@oushiei120 oushiei120 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2023
@kbenoit
Copy link
Collaborator

kbenoit commented Jun 2, 2023

This should still work fine. If you can supply a reproducible example using reprex::reprex() I can examine this further.

@oushiei120
Copy link
Author

oushiei120 commented Jun 2, 2023

This should still work fine. If you can supply a reproducible example using reprex::reprex() I can examine this further.

I found some guy meet the same issue like me

error-in-usemethoddocvars-no-applicable-method-for-docvars

docvars-produces-an-error-after-update-to-r-version-4-3-0

@kbenoit

@oushiei120 oushiei120 reopened this Jun 2, 2023
@kbenoit
Copy link
Collaborator

kbenoit commented Jun 2, 2023

Hi @oushiei120 - Yes I am aware of those posts, but unlike you, they posted them in the wrong location. They should be issues here on GitHub, not questions on SO. So you did well by posting that here.

However to diagnose this issue, I would need to see your exact session output, including the part where it states your package version information. If possible, some data that illustrates the problem so that I can reproduce it.

We introduced some changes to docvars() in the last two releases and the way they work with the readtext package, and this is likely causing your issues, but we cannot know without this information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants