R: How to fix namespace error?

Tag: r , namespaces Author: feifei602 Date: 2014-02-07

I want to use the NGramTokenizer from RWeka but for some reason I get this error: I need the following function

BigramTokenizer <- function(x) NGramTokenizer(x, Weka_control(min = 2, max = 2))
bigramWords.dtm <- DocumentTermMatrix(Corpus(VectorSource(SentenceVector)), control = list(tokenize = BigramTokenizer))

So I installed RWeka:

package ‘RWekajars’ successfully unpacked and MD5 sums checked
package ‘RWeka’ successfully unpacked and MD5 sums checked


> library(RWeka)
Error : package ‘methods’ does not have a namespace
Error: package or namespace load failed for ‘RWeka’

I also get namespace errors installing packages like:

Installing package into ‘C:/Users/SomeUser/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
  dependency ‘methods’ is not available
also installing the dependencies ‘assertthat’, ‘BH’
Did you update all of your packages and restart R? Seems like it might just be a quirk.
@Thomas Thank you for the fast help. Yes. I restarted several times also I used rm(list = ls()). Packages are also up to date. I user RStudio is this a problem? EDITstart I tried even in R directly - use Windows editEND
Do you have Java installed on your machine?
@Thomas The actual version of Java Runtime is installed. However (but I think this shouldn't matter) it is not active for the browser.
Yea, I can't offer more help because I don't have Java on the machine I'm currently on, but received a similar (albeit somewhat different) error trying to load the package. If you can track down the difference between the two situations, you should definitely post it as an answer. Answering one's own questions is encouraged, when it will help others in a similar situation.