Current location - Education and Training Encyclopedia - Graduation thesis - How to use RStudio efficiently
How to use RStudio efficiently
RStudio Server is a web-based open source editor created by RStudio. If you are familiar with the desktop version of RStudio, it is basically not difficult for you to use the RStudio server.

exist

In practical projects, most of our servers are based on Linux, such as ubuntu and centos.

Wait a minute. Sometimes these operating systems don't provide graphical interfaces, so the server version of RStudio comes in handy. Start RStudio

After the Server, after entering a page in the browser, you can use the RStudio editor like the desktop version. When R's code has a bug on the server, the online patch is

At this time, the RStudio server is bound to be used, so it is urgent.

This time, we continue to use Docker artifact to quickly initialize the configuration of RStudio server environment, and use Git to realize the version control of the code.

prepare

Ubuntu server

Step 1: Install RStudio server.

First, we install a standard RStudio server through docker.

docker pull quantum object/docker-r studio

docker run-d-p 8787:8787 quantum object/docker-r studio

In this way, you can access the login interface of rstudio at the 8787 port of the computer.

Step 2: Initialize the RStudio account.

Next, we need to initialize an account of rstudio.

Docker exec -it container -id /bin/bash

Adduser harryzhu # sets a new user name.

Passwd harryzhu # sets the password for this user.

Mkdir /home/harryzhu # Initialize the workspace

Chmod -R harryzhu /home/harryzhu # Empowered Workspace

Step 3: Install git

Then, we enter the server of rstudio, and we intend to introduce git version control.

Sudo apt-get installs git- kernel.

Step 4: Solve the authentication problem of ssh.

You may encounter SSL certificate problems when using git. For the problem of ssh, we can choose to establish an ssh authentication key, or set it as ignore in git.

Generate key:

$ssh-keygen -t rsa

Generating public/private key pair.

Enter the file where the key is saved (/root/). ssh/id_rsa):

The directory "/root/" has been created. Shh.

Press Enter continuously to skip the password setting.

Display key information:

sudo cat /root/。 ssh/id_rsa.pub

If ssh authentication is not required, you can also choose to ignore:

Git configuration-global tes(package="broom ")

Hadley wickham is the chief scientist of RStudio and an adjunct professor of statistics at Rice University. He will introduce all kinds of R packages that he thinks you should know, and outline big data and R, but mainly explain why he thinks you should not worry about big data.

Garrettgman:packrat and virtualization technology

Teaching video address

you

Have you ever had the experience of co-development: running the perfect R code on your own machine and copying it to another colleague's machine, many R packages need to be reinstalled, and some R packages even depend on different versions?

Ben. Now, you don't need to use global virtualization technologies such as Docker or vagger, just use the packrat package to ensure that the dependency problem of your R project is well solved.

Run once, run everywhere.

If (! require(pack rat)){ install . packages(" pack rat ")}

GetOption("repos") # displays the code image source.

Packrat:: bundle() # Pack and virtualize the current environment.

Packrat:: Unbundle (bundle = "xxx.tar.gz", where = "." ) # Load the packaged environment.

Packrat:: opts $ local.repos ("~/r") # Set the local repos as the path.

Packrat:: install _ local ("pryr") # local installation.

Hadley Wickham: Git works with teams.

Teaching video address

Teamwork: With Git and GitHub, you can easily collaborate with others. You no longer need to back up documents with email attachments, and you no longer need to fight for editing rights on Dropbox. On the contrary, you can work independently, and finally you just need to combine your achievements.

Version control: Git allows us to roll back to any previous point in time when we make a major mistake. We can also review a historical record we have done before and track the formation process of bugs.