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

dfm_lookup error: intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) : invalid character indexing #946

Closed
pbradl42 opened this issue Sep 6, 2017 · 2 comments

Comments

@pbradl42
Copy link

pbradl42 commented Sep 6, 2017

I found this weird thing. dfm_lookup is crashing with the above error in certain cases when 'exclusive=TRUE.' Here's a minimum working example. I don't know why "featured_story_content_h2" is important, but it appears to be.

I'm using quanteda 0.99.

 corpus(c("featured_story_content_h2", "aaaaa", "bbbbb", "ccccc")) -> testCorpus 
 #corpus(c("aaaaa", "bbbbb", "ccccc")) -> testCorpus # Works
 dictionary(list(foo = c("xxxxx"), bar = c("yyyyy", "zzzzz"))) -> controlDict
 dictionary(list(foo = c("aaaaa"), bar = c("yyyyy", "zzzzz"))) -> testDict
 dfm(testCorpus, tolower = TRUE, 
 remove_numbers = TRUE, remove_punct = TRUE, remove_separators = TRUE,
 remove_twitter = FALSE, stem = FALSE, ngrams=c(1:2)) -> myDFM

 dfm_lookup(myDFM, dictionary=controlDict, exclusive=FALSE) # Succeeds
 dfm_lookup(myDFM, dictionary=testDict, exclusive=TRUE) # Succeeds
 dfm_lookup(myDFM, dictionary=testDict, exclusive=FALSE) # Fails
#**Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) : 
#  invalid character indexing**

Any ideas?

@pbradl42
Copy link
Author

pbradl42 commented Sep 6, 2017

Found another phrase that causes the same error in dfm_lookup: "features_archive20172016201520142013media" -- Could this be because of 'feature' in these phrases?

@pbradl42
Copy link
Author

pbradl42 commented Sep 6, 2017

Yup - if you run the DFM through

dfm_remove(myDFM, c('feature*')) -> myDFM

first, dfm_lookup will complete successfully.

kbenoit added a commit that referenced this issue Sep 7, 2017
…_options("base_featname")`

- Fixes #946
- affected `dfm_select()`
- affected `dfm_lookup()`
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

1 participant