1

I'm using the quanteda package to construct DFMs in order to train a model on a dfm so that I can predict values for a new unknown dataset. Using predict() this works fine as long as the both sets have the same number of features, if not I get this error:

Cholmod error 'A and B inner dimensions must match'

To ensure that the number of features is identical one can use selectFeatures or the argument keptFeatures in the dfm-function.

My problem is that I simply cannot find these functions. I have:

  • re-installed the quanteda package.

  • restarted R.

  • made sure I have the newest package version 1.2.0

  • checked the github page for quanteda to check if the functions have been removed.

All to no avail. All I get are these error messages:

    textVec1 <- c("This is text one.", "This, the second text.", "Here: the third text.")
    textVec2 <- c("Here are new words.", "New words in this text.")
    dfm1 <- dfm(textVec1)
    dfm2a <- dfm(textVec2)
    dfm2b <- dfm(textVec2, keptFeatures = dfm1)

Warning messages:

1: Argument keptFeatures not used.

2: Argument keptFeatures not used.

    dfm <- selectFeatures(dfm1, features = dfm2)

Error in selectFeatures(dfmshort, features = dfmacts) : could not find function "selectFeatures"

Do I need an additional package to run these functions?

Scipione Sarlo
  • 1,470
  • 1
  • 17
  • 31
Hal
  • 75
  • 6
  • Hi, welcome to StackOverflow! You need to make a more expanded issue description, with some small snippets of code and by explicitly explaining bugs – Scipione Sarlo May 06 '18 at 18:57
  • It seems that selectFeatures is no more a function of `quanteda` package: ftp://cran.r-project.org/pub/R/web/packages/quanteda/quanteda.pdf. The same thing about keptFeatures, which is not an argument of `dfm` function – Scipione Sarlo May 06 '18 at 20:02
  • You should replace the fourth line with `dfm2b <- dfm_select(dfm2a, pattern = dfm1)`. Please look at the man pages for the functions you are calling for a detailed description of the valid arguments, and the package index for the function names. – Ken Benoit May 06 '18 at 20:09
  • Thanks for the suggestions. It seem like the function `dfm2b <- dfm_select(dfm2a, pattern = dfm1)` works. – Hal May 07 '18 at 11:00

0 Answers0