cturbelin / rserve-php

Rserve client php library
Other
45 stars 24 forks source link

unable to evaluate -Rvest #6

Open remyagss opened 8 years ago

remyagss commented 8 years ago

Hi, I am trying to execute the following code using rserve-php. but it returns 'unable to evaluate'. I am using Rvest to webscrap data from twitter. Code : $cnx->evalString("url <- 'https://twitter.com/search?f=tweets&q=to:test&src=typd'"); $cnx->evalString("tweets <- url %>% read_html() %>% html_nodes(xpath='//*[@class='js-tweet-text-container']') %>%");

Can you please help me to resolve this?

cturbelin commented 8 years ago

Hi, There is probably an error raised by R that is masked in the result (if an error occured on the R side, the protocole return an error state and the error message will be masked). To handle this, just wrap the R code with a try(). For example : `$command = 'r= try({'.$command.'}, silent=T); if( inherits(r,"try-error")) { r = structure(list("try-error"=1,message=unclass(r))) }; r'; The returned result with be valid for the Rserve client but you will be able to catch the error occured in R.