to call a script in r we will execute below code
first try
second try is copy out everything from something.R to vs2013 the purpose of source code is to analysis text from twitter source as shown in link here
source("D:\something.R")
but when i try to do in vs2013 with following 2 samples, it did not work, anyone can guide me?first try
REngine.SetEnvironmentVariables();
REngine engine = REngine.GetInstance();
engine.Initialize();
var sentiment_R = engine.Evaluate("source('D:\something.R')");
above will return sentiment_R into list as shown below copy from immediate windowsRObjectType = List
base: RObjectType = List
Engine: {RDotNet.REngine}
IsInvalid: false
IsProtected: true
Type: List
instead of return a function it return be a list and i cannot assign value to the function from something.R scriptsecond try is copy out everything from something.R to vs2013 the purpose of source code is to analysis text from twitter source as shown in link here
engine.Evaluate("score.sentiment = function(sentences, pos.words, neg.words, .progress='none')" +
" { require(plyr) require(stringr)" +
"scores = laply(sentences, function(sentence, pos.words, neg.words) { " +
"sentence = gsub('[[:punct:]]', '', sentence)" +
"sentence = gsub('[[:cntrl:]]', '', sentence)" +
"sentence = gsub('\\d+', '', sentence)" +
"sentence = tolower(sentence)" +
"word.list = str_split(sentence, '\\s+')" +
"words = unlist(word.list)" +
"pos.matches = match(words, pos.words) neg.matches = match(words, neg.words)" +
"pos.matches = !is.na(pos.matches) neg.matches = !is.na(neg.matches) score = sum(pos.matches) - sum(neg.matches)" +
"return(score)}, pos.words, neg.words, .progress=.progress )scores.df = data.frame(score=scores, text=sentences)return(scores.df ) } " ) ;
it return me : unexpected symbol
hope someone can provide link or solution to me thank in advance :)