Reputation: 1
I apologize if my formatting of this topic isn’t correct this is my first time posting in the community and I will try and do my best.I have been working on this problem for awhile but have been struggling to address it. I am currently following the book “Text Mining with R: A Tidy Data Approach” and am on the part that uses the ‘tm.plugin.webmining’ package to do a sentiment analysis on financial articles. The initial problem is that when I attempted to load the package from the library it would report and error as such.
Error: package or namespace load failed for ‘tm.plugin.webmining’: .onLoad failed in loadNamespace() for ‘rJava’, details: call: dyn.load(file, DLLpath = DLLpath, …) error: unable to load shared object ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so’: dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so Reason: image not found
After doing some research I found out that this had to do with the way R and Java communicate on mac OS High Sierra. So to fix this I followed the followed this article. and it appeared to work. once I fixed the issue with java and r I was finally able to load the ‘tm.plugin.webmining’ package. but when I tried to run the examples from the book to load the corpus, I got the following error.
StartTag: invalid element name Extra content at the end of the document Error in mutate_impl(.data, dots) : Evaluation error: 1: StartTag: invalid element name 2: Extra content at the end of the document
I cannot seem to find information on this anywhere and do not have enough experience in this to fix this issue myself, so any insight, or ideas I could attempt to fix this problem are greatly appreciated. Below I posted the code I ran that gave me this issue. Thank you in advance.
`library(tm.plugin.webmining)
library(purrr)
library(dplyr)
company <- c("Microsoft", "Apple", "Google", "Amazon",
"Facebook","IBM", "Yahoo", "Netflix")
symbol <- c("MSFT", "AAPL", "GOOG", "AMZN", "FB", "IBM", "YHOO",
"NFLX")
download_articles <- function( symbol) {
WebCorpus(GoogleFinanceSource(paste0("NASDAQ:", symbol)))
}
stock_articles <- data_frame(company = company, symbol = symbol) %>%
mutate(corpus = map(symbol, download_articles))`
Upvotes: 0
Views: 776
Reputation: 336
I had the same problem while executing the code, and found a workout, as shown below:
library(tm.plugin.webmining)
library(purrr)
company <- c("Microsoft", "Apple", "Google",
"Amazon", "Facebook", "Twitter",
"IBM", "Yahoo", "Netflix")
symbol <- c("MSFT", "AAPL", "GOOG", "AMZN", "FB",
"TWTR", "IBM", "YHOO", "NFLX")
download_articles <- function(symbol) {
WebCorpus(YahooFinanceSource(paste0("NASDAQ:", symbol)))
}
stock_articles <- data_frame(company = company,
symbol = symbol) %>%
mutate(corpus = map(symbol, download_articles))
Inside the WebCorpus function, use YahooFinanceSource()
, instead of GoogleFinanceSource()
.
Upvotes: 1