How Install R / R Studio on CentOS 7

install r rstudio centos

An article on how to install R programming language and R studio IDE on Centos 7 server. The R programming language is a free software implementation of S programming language, and it is largely compatible with it. It is a GNU project and it is most popular language for statistics and data science, rivaled only by Python. Today we will install the R and R Studio IDE on Centos 7 server. This would allow you to do number crunching on the remote server from your laptop without compromising the battery life.

Creating non-root user for R Studio

First thing we need to do is add user. The R studio is not designed to be used by root, so we will make non-root user with sudo rights.

adduser miki

We will crate password for new user

passwd miki

And add user to wheel group so he can use sudo

usermod -aG wheel miki

Finally log in as new user

su miki

Installing R and R Studio

After logging in a s non root we continue with installing the R. The R software is present in repository known as EPEL, or Extra Packages for Enterprise Linux. Lets add that repository

sudo yum install epel-release

Next we will install R software

sudo yum install R

This will install lots and lots of software that are dependencies of R. It might take some time. Next we move to install of the server IDE, rstudio-server. We will download it from the site


And then install it

sudo yum install --nogpgcheck rstudio-server-rhel-1.0.44-x86_64.rpm

It will immediately start the service, so lets check if it is running  correctly

systemctl status rstudio-server.service
R studio

Like we see it is running fine so we can proceed to connecting to the server. The address would be ip of your server and port 8787, like this http://youriporhosname:8787/. When you connect you will get a login screen like this

r studio

You log in with your non-root Linux user that you have created. After logging in, you would get to IDE like this

r studio ide

Adding packages from CRAN

On above picture we see the R prompt where you can type commands. This commands will execute as non-root user. When you want to add new packages from CRAN ( Comprehensive R Archive Network) you generally need to use root user. That way you will have packages usable for all users, while when adding as non-root, you will be able to use it only as that user. You can add packages as root outside of IDE, type sudo -i R on your server bash shell logged in as user. As we are going to add packages that are not entirely written in R, we need to add build tools first

sudo yum groupinstall "Development Tools"

Then we can log in to R prompt

sudo -i R

And there type the following to install package we need:


You will get prompted for the mirror from where to fetch the package. Choose which is closest to you.

--- Please select a CRAN mirror for use in this session ---

1: 0-Cloud [https] 2: Algeria [https]
3: Australia (Melbourne) [https] 4: Australia (Perth) [https]
5: Austria [https] 6: Belgium (Ghent) [https]
7: Brazil (RJ) [https] 8: Brazil (SP 1) [https]
9: Bulgaria [https] 10: Canada (MB) [https]


After package is fetched, it will compile it and we can move to next package we need


This time you wont get prompted for mirror, as previous choice got saved. After all this is installed, we can go back to the IDE in our browser.

Making the Statistical graph in R-Studio

As an example, we are going to make a graph of Hat stock first load the library you are going to use


Add environment variable

data <- new.env()

And plot data

getSymbols('RHT', data)
RHT stock


We have successfully installed the R studio and R programming language to remote server. This enables you to do serious number crunching when you are on the go, and it is more practical than heating your laptop. Minimum requirements for installation are 1GB of ram and one core, but you normally want many cores and lots of ram, or else why would you run server? If you want to learn more about R, good place to start is official R manuals. This is all for today, thank you for reading.

5 Comments... add one

  1. Hi there

    I've already installed R but failed to installing R studio. I just followed your instruction but something wrong when I was run with :

    $ sudo yum -y install --nogpgcheck rstudio-server-rhel-1.0.44-x86_64.rpm
    Loaded plugins: fastestmirror, langpacks
    Examining rstudio-server-rhel-1.0.44-x86_64.rpm: rstudio-server-1.0.44-1.x86_64
    rstudio-server-rhel-1.0.44-x86_64.rpm: does not update installed package.
    Error: Nothing to do

    What mean is it? And how to solve it? Thank you for your kind help.

  2. After intaslling EPEL, I typed
    yum install R
    and the system responds
    Loaded plugins: fastestmirror, security
    Setting up Install Process
    Repository epel-testing is listed more than once in the configuration
    Repository epel is listed more than once in the configuration
    Loading mirror speeds from cached hostfile
    No package R available.
    Error: Nothing to do

    Any suggestions?


Leave a Comment