Site icon R-bloggers

RServe – Introduction and Installation

[This article was first published on R – StudyTrails, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Related Tutorials

First Sample Program

Introduction

RServe is an R package that allows other applications to talk to R using TCP/IP. It creates a socket server to which other applications can connect. RServe provides client implementation for common languages such as C/C++, Java and PHP. In this series of tutorials we will look at how to use java to make calls to R using RServe. Features of RServe are ::

Platform – Windows of linux?

RServe can be installed on both windows and linux platform, however it is recommended to install and use it on a linux platform. To use R with java on a single windows machine it would be better to use the native client JRI instead. The RJava Eclipse Plugin can be used to set up JRI for use within a single windows machine. However, if you are looking for an enterprise level solution that supports multi-threading then RServe is a better choice.

Installation and Starting RServe

Installing RServe is very simple. Start R and on the command prompt type in install.packages(“RServe”,dest=”&ltDEST_DIR&gt”). The DEST_DIR stores the RServe source package. We will need this to get the java client. This will download and install RServe.

RServe can be started in two ways

    • Directly from R. On the R console type library(“Rserve”). This will load RServe
    • On the console type Rserve(). This will start RServe in daemon mode. Note that R does not have to be running in order to use RServe. You can quit the R console and RServe will still run.
    • Since RServe runs as a daemon, you can shut it down gracefully from the client (we shall see that later). However, to explicitly kill RServe on a linux box, type in ps -ef | grep Rserve. Look for the RServe process. you should see something like &ltR_HOME&gtRserve/libs//Rserve-bin.so. Note down the process id and kill the process using kill -9 process_id
  1. From the unix console. Start RServe using the command R CMD RServe. This will again start RServe as a daemon.

The post RServe – Introduction and Installation appeared first on StudyTrails.

To leave a comment for the author, please follow the link and comment on their blog: R – StudyTrails.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.