Tutorial

How To Set Up RStudio On An Ubuntu Cloud Server

Published on April 16, 2013
author

Di Wu

How To Set Up RStudio On An Ubuntu Cloud Server

What is RStudio?

RStudio IDE is an open source Integrated Development Environment for the statistical analysis program R. RStudio Server provides a web version of RStudio IDE that allows easy development on a VPS. Since our VPSs are billed by the hour, it's surprisingly cheap to spin up a 24 core instance, crunch some data, and then destroy the VPS.

Installing RStudio In a VPS

First, install R, apparmor, and gdebi.

sudo apt-get install r-base libapparmor1 gdebi-core

Next, download and install the correct package for your architecture. On 32-bit Ubuntu, execute the following commands.

wget http://download2.rstudio.org/rstudio-server-0.97.336-i386.deb -O rstudio.deb

On 64-bit Ubuntu, execute the following commands.

wget http://download2.rstudio.org/rstudio-server-0.97.336-amd64.deb -O rstudio.deb

Install the package.

sudo gdebi rstudio.deb

Creating RStudio User

It is not advisable to use the root account with RStudio, instead, create a normal user account just for RStudio. The account can be named anything, and the account password will be the one to use in the web interface.

sudo adduser rstudio

RStudio will use the user's home directory as it's default workspace.

Using R Studio

RStudio can be access through port 8787. Any user account with a password can be used in RStudio.

Rstudio Sign In

Let's test that RStudio is working correctly by installing a quantitative finance package from CRAN, the R package repository.

Run the following command inside RStudio to install quantmod.

install.packages("quantmod")
Rstudio 1

Next, let's test out RStudio's graphing capabilities by plotting the stock price of Apple. The graph will appear in the bottom right panel of RStudio.

library('quantmod')
data <- new.env()
getSymbols('AAPL', data)
plot(data$AAPL)
Rstudio 2

R is a really powerful tool and there are hundreds of useful packages available from CRAN. You can learn the basics of R at Try R.

To learn how to install R packages from CRAN and GitHub and how to ensure that these packages are made available for all users on the same Droplet, check out How To Set Up R on Ubuntu 14.04.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Di Wu

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

This mostly worked. Thanks. However, I had to enable more swap space in order to install packages. I did that by following the advice here:

http://stackoverflow.com/questions/17173972/how-do-you-add-swap-to-an-ec2-instance

Hi, in ubunto 18 and 20 I have:

~# sudo gdebi rstudio.deb Reading package lists… Done Building dependency tree
Reading state information… Done Reading state information… Done This package is uninstallable Dependency is not satisfiable: libssl0.9.8

I followed the instructions and was able to get rstudio working perfectly, however I now have to update R and am unable to change the version of R that is used in rstudio. Anybody know how to do this? I tried changing the value of RSTUDIO_WHICH_R variable and it didn’t work.

Similar issue ‘connection timed out’ If like me you had followed other Digital Ocean tutorials and installed ufw before installing R Studio I hope this solution from askubuntu, which worked for me, will also help you:

sudo ufw allow 8787

I followed these instructions and everything seemed to work. But if I try to run a shiny app or even just access a help page from within R studio I get this error message in the browser window:

This site can’t be reached 127.0.0.1 refused to connect.

Any ideas what is wrong?

Work great but it could be better.

  1. An error would pop up
   Error in tools:::httpdPort > 0 : 
   comparison (6) is possible only for atomic and list types

which someone suggested to try a newer version of the rstudio as it is not matched with the R version (which I still cannot remove the error message) but still the sample work great

  1. if you use the rstudio reverse proxy example (under rstudio), you can setup to use 80 and not 8787. Still working on how to enable both clojure and rstudio as the same time.

@daattali I’ve set up ufw and it seems to be blocking me to see a shiny app when i runApp. How to solve this?

Thanks.

I am new to Digital Ocean and Linux, so may have make a rookie mistake.

I have tried all the instructions, and I can log into R, but I cannot access RStudio.

When I type in the ip address:8787 I get an error message “webpage is not available”

What am I doing wrong?

Thanks

This comment has been deleted

    I have not been able to connect, I already change the size of the droplet and no change. I try $ sudo rstudio-server verify-installation rstudio-server stop/waiting rstudio-server start/running, process 2258

    so everything is ok.

    Any thoughts?

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Join the Tech Talk
    Success! Thank you! Please check your email for further details.

    Please complete your information!

    Become a contributor for community

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    DigitalOcean Documentation

    Full documentation for every DigitalOcean product.

    Resources for startups and SMBs

    The Wave has everything you need to know about building a business, from raising funding to marketing your product.

    Get our newsletter

    Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

    New accounts only. By submitting your email you agree to our Privacy Policy

    The developer cloud

    Scale up as you grow — whether you're running one virtual machine or ten thousand.

    Get started for free

    Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

    *This promotional offer applies to new accounts only.