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 -- View this message in context: http://old.nabble.com/Can%27t-pass-file-name-as-parameter-to-Corpus-function-tp26159498p26159498.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.