IBM  Data Science  Experience

Using RStudio in IBM Data Science Experience

Data Science Experience has helped me to move all of my work that is in Jupyter notebooks and RStudio from my local environment to the cloud. This works well for me because I can now pick up projects from any machine, with all of my data and configurations ready to go. It's been great to move to a single tool that has RStudio, notebooks, and Spark available with a few clicks.

With that being said, any time you move to a new tool there is a learning curve. I hope this blog post helps people who are new to Data Science Experience or to working with RStudio in the cloud.

Where to find RStudio

In the Data Science Experience left side menu you have the option to select Notebooks, Projects, or RStudio.

To get into RStudio, click the link from this menu.

Loading packages

Just as in a local version of RStudio, you can install an R package by using the RStudio interface. To do this, click Packages in the bottom right section of RStudio, then click Install below it.

Next, type the names of the packages that you want to install in the pop-up, and click Install.

If you want to install packages from within your script, use the following code where "myPackage" is replaced with the name of your package.

install.packages("myPackage")  
library(myPackage)

Adding local files

To add files from your local environment to used with RStudio in Data Science Experience, click Files in the bottom right section of RStudio. This is where you can create folders, upload files, and delete files.

If you click Upload, you can select a ZIP file that will create a new folder with the contents in the folder. You can also select a single file to upload.

Using the uploaded files

Because the files that you added are now in the server file structure, you will read them from there. For this article, I added a file named train.csv into the Home directory of RStudio. If you want to save your file in a different location, you can create a new folder or select existing folders to navigate to them.

After the file is uploaded, click the file name to see a preview in a data viewer.

To access this file in R, set the working directory as the directory with the data set. You can do this by navigating to the directory with the file and clicking More, then click Set as Working Directory.

After you have the directory with the data set as the working directory, reference the file in your R script by the file name:

myd <- read.csv('train.csv')  
head(myd)

Now you are ready to use RStudio in IBM Data Science Experience. If you aren't a member yet sign up here.

Greg Filla

Read more posts by this author.

Chicago

Subscribe to IBM Data Science Experience Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!