Skip to content

dfm_remove behaves like dfm_keep if pattern is dfm #1320

Description

@theresagessler

Hi,
I a trying to check the dfference between two dfms when selecting features based on one. It seems that if the pattern is a dfm (rather than e.g. a character vector), dfm_remove acts as dfm_keep. First occured with quanteda 1.0 but it still behaves the same after updating
And on this occasion, thanks for all the great work on the package, I was really happy about the new structure form 1.0 upwards!

This is a short reproduction of the problem:

test <- c("this is a test text")
test2 <- c("this is another one")
test_dfm <- dfm(test)
test2_dfm <- dfm(test2)
keep <- dfm_keep(test_dfm, test2_dfm)
remove <- dfm_remove(test_dfm, test2_dfm)
featnames(keep)
## [1] "this"    "is"      "another" "one"    
featnames(remove)
## [1] "this"    "is"      "another" "one"    
diff <- setdiff(featnames(test_dfm), featnames(test2_dfm))
diff_dfm <- dfm_keep(test_dfm, diff)
featnames(diff_dfm)
## [1] "a"    "test" "text"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions