[R] Can't pass file name as parameter to Corpus function
Uwe Ligges
ligges at statistik.tu-dortmund.de
Wed Nov 4 11:28:35 CET 2009
The function Corpus seems to be in some contributed package. If you
think you found a bug in a contributed package, please contact the
package maintainer.
Best wishes,
Uwe Ligges
renjl0810 wrote:
> I'm working on a small project to extract high-frequency terms from a
> document and then display those terms in web page. To this end, I've to pass
> the file name as parameter to the Corpus function to build a corpus of only
> one document. I can build the corpus using the code below interactively in
> R. But calling the function with a file name as the parameter I got the
> error message saying "Error in eval(expr, envir, enclos) : object
> 'strFileName' not found"
>
> test<-function(strFileName) {
> src <- URISource(strFileName)
> cor <- Corpus(src, readerControl = list(reader = readPDF, language =
> "en_US", load = TRUE))
> }
>
> After running the following code in R I checked the docURISource$URI and the
> value is "strFileName" rather than "C:\\Temp\\readme.txt". I also checked
> the URI when I was debugging the function and the URI is also "strFileName"
> rather than "C:\\Temp\\readme.txt".
>
> strFileName <- "C:\\Temp\\readme.txt"
> docURISource = URISource(strFileName, encoding = "UTF_8")
> docCorpus = Corpus(docURISource)
>
> So it seems when running interactively the URI contains strFileName as a
> variable but when called as a function, the URI contains strFileName as the
> actual value. Can anybody point out what's the problem?
>
> thanks in advance!!
>
> Jianli
More information about the R-help
mailing list