Rhostudio is a tool for remote execution of programs written in the R statistical programming language. It lets you execute R code on remote machines, which can be clusters, personal computers, virtual machines or any other computer accessible over the network. For example, you can use Rhostudio to submit a computation from your laptop to a remote server and get the result back almost instantly. You don’t need to copy your code to the server and keep it there for future runs; you just tell R where to find the code and let it take care of everything else. This blog post will give you an overview of what Rhostudio can do for you as an R user who wants to optimize their workflow and spend more time exploring data and modeling new phenomena rather than dealing with mundane tasks like managing files and folders.
Why use Rhostudio?
Rhostudio is an essential tool for users who do their analysis in an environment where they don’t have direct access to the data. This often happens in organizations that don’t have a Data Science department, or in environments where there are only a few data scientists who need to collaborate with a larger group of stakeholders. When R is deployed in a server-based setting, every user who wants to run R code has to log in to that server and use the R shell. This is slow, cumbersome and error-prone. Imagine having to wait a few minutes between starting R and launching the first code you wrote after logging in. Then imagine having to copy files from the remote server to your local machine for further analysis. Rhostudio solves all of these problems by letting you run R code in a remote session, which means that you don’t have to log in to the server where your code is running. You just have to use R to find out where the code is and tell it to run. The rest is handled by Rhostudio.
Rhostudio is distributed with R itself. In fact, it’s part of the core R installation. You don’t need to download or install anything else. All you have to do is to load the library with the command library(Rhostudio) at the beginning of your R session and you’re good to go.
Running code in a remote session
You’ll use the Rhostudio session() function to run R code in a remote session. The first thing you need to do is to specify where your code is located. This can be a local file, a remote file or an R script generated by a tool like knitr. Here’s an example: Imagine that you have code that generates some plots in a file called plots.R. You want to run this code in a remote session and get the plots printed to your local machine. First, you need to tell R where the code is located. You do this with the function sessionPath(), which takes the name of the file as an argument. This is what the code for running the plots in a remote session looks like: sessionPath(“plots.R”) ##