I use Twitter anomaly detection algorithm in my project. For this purpose I use Rserve library to run R code in my Java application.
My Java code:
RConnection connection = new RConnection();
connection.voidEval("library(AnomalyDetection)");
connection.eval("res <- AnomalyDetectionTs(data.frame(/*list of timestamps*/,/*list of values*/), direction='both', plot=FALSE, longterm=TRUE)");
And, as a result, I got this output:
$anoms
timestamp anoms
1 1980-09-25 16:05:00 21.3510
2 1980-09-29 06:40:00 193.1036
3 1980-09-29 21:44:00 148.1740
To get results now I'm using this not nice solution:
connection.eval("write.csv(res[['anoms']],file='anom.csv')");
Then I open this file in Java and parse the results.
So, how to get the output results in Java using Rserve possibilities for data.frame structure?