On 10/15/2009 08:12 PM, PDXRugger wrote:> I am looking to do some text analysis using R and have run into some issues
> with some of the packages. Im not sure if its my goofy Vista OS or what
but
> using R 2.8.1 i s relatively successful loading the text but the rJava
> package was messed up somehow:
>
> library(tm)
>> library(rJava)
> Error in if (!nchar(javahome)) stop("JAVA_HOME is not set and could
not be
> determined from the registry") :
> argument is of length zero
On windows rJava tries to guess where java lives at runtime by poking
into the registry. It is possible that the registry has changed for
vista ... I don't know
What you can do is tell rJava where java lives yourself by setting the
JAVA_HOME environment variable.
... Now the fact that you see "argument is of length zero" is a bug
because the test should be : if( is.null(javahome) || !length(javahome)
|| nchar(javahome ) ) ..; but fixing this bug won't fix your problem.
> In addition: Warning message:
> package 'rJava' was built under R version 2.9.1
> Error : .onLoad failed in 'loadNamespace' for 'rJava'
> Error: package/namespace load failed for 'rJava'
You need to either install an older version of rJava or a more recent
version of R.
>>
>> #Set documents directory
>> DIR<- "G:/TextSearch/Speeches"
>>
>> #Load corpus
>> speech<- Corpus(DirSource(DIR), readerControl = list(reader =
readPlain,
> + language = "en_US", load = TRUE))
>>
>> #Remove stopwords
>> speech<- tmMap(speech, stripWhitespace)
>> speech
> A corpus with 2 text documents
>
>> tdm<-TermDocumentMatrix(speech)
> Error in if (!nchar(javahome)) stop("JAVA_HOME is not set and could
not be
> determined from the registry") :
> argument is of length zero
> Error: .onLoad failed in 'loadNamespace' for 'rJava'
>
> --------------------------------------------------------
> So the initial question is whats going on with the rJava package? I get the
> same error when i try and load the package and then when i try and utilize
a
> function from the package.
>
> I tried installing 2.9.2 and ran into more problems when running the lines:
>
>> utils:::menuInstallPkgs()
Quit R, Start R again without loading the tm package, and then try again
> Warning: package 'tm' is in use and will not be installed
>> speech<- tmMap(speech, stripWhitespace)
> Error: could not find function "tmMap"
>
> the package is installed correctly but its not able to pick it up in this
> version of R. Again, im not sure if its somehting with Vista or what.
> Thanks guys and gals
>
> Cheers,
> JR
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/BcPw : celebrating R commit #50000
|- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
`- http://tr.im/yw8E : New R package : sos