RStudio

R is a popular statistical analysis and machine-learning package that includes tests, models, analyses, and graphics, and enables data management. RStudio, included in IBM Watson Studio, provides an IDE for working with R.

Data format
All data file types in the RStudio server file structure or stored in the IBM Cloud Object Storage bucket associated with the project
Tables in relational data sources
Data size
Any

Accessing RStudio

RStudio is integrated in IBM Watson Studio projects and can be launched after you create a project.With RStudio integration in projects, you can access and use the data files that are stored in the IBM Cloud Object Storage bucket associated with your project in RStudio.

To start RStudio in your project:

  1. Click RStudio from the Launch IDE menu on your project’s action bar.
  2. Select a runtime.

    A compute environment runtime with the selected hardware size is activated and the development environment opens.

Watch this video to see an overview of the RStudio IDE.

Figure 1. Video iconOverview of the RStudio IDE
This video provides an overview of the RStudio IDE.

Working with data files

In RStudio, you can work with data files from different sources:

  • Files in the RStudio server file structure, which you can view by clicking Files in the bottom right section of RStudio. This is where you can create folders, upload files from your local system, and delete files.

    To access these files in R, you need to set the working directory to the directory with the data files. You can do this by navigating to the directory with the files and clicking More > Set as Working Directory.

    Be aware that files stored in the Home directory of your RStudio instance are persistent within your instance only and cannot be shared across environments nor within your project.

    Watch this video to see how to load data to RStudio.

    Figure 2. Video iconLoad data into RStudio
    This video shows you the different ways to load data into RStudio.
  • Data files that are stored in the IBM Cloud Object Storage bucket associated with your project. When RStudio is launched, the IBM Cloud Object Storage bucket content is mounted to your Home directory under the project-objectstorage folder. You are permitted to view the content of data files in this folder only. You can read and update data files in that folder, however you cannot delete files.

    Restriction: You cannot load files to this folder at this time.

    If new data assets are added to the project which you want to access from RStudio, you need to refresh the folder.

    See how to read and write data to and from Cloud Object Storage.

  • Data stored in a database system.

    Watch this video to see how to analyze Db2 Warehouse on Cloud data in RStudio.

    Figure 3. Video iconAnalyze Db2 Warehouse on Cloud data in RStudio
    This video shows you how to analyze Db2 Warehouse on Cloud data in RStudio.

Adding or deleting project assets

You should upload data files to use in your notebooks in RStudio from the find and add data sidebar on your project’s Assets page because these files are automatically added as data assets to your project.

However, if you worked with data files in RStudio, you can add them to your project as project data assets. These files must be in the project_data/rstudio/data_assets folder. To add these files as data assets to the project:

  1. On the Assets page of the project, click the Find and Add Data icon (Shows the find data icon) and select the Files tab.
  2. Select the files you want to add to the project as assets.
  3. From the Actions list, select Add as data asset and apply your changes.

If you delete a data asset from the project_data/rstudio/data_assets folder in RStudio, the file is no longer listed in the add data sidebar under the Files tab when you click the Find and Add Data icon on the project Assets page. However it is still listed as a data asset on the Assets page of your project. Delete the entry in the data assets list by:

  1. Selecting the data asset from the list.
  2. From the Actions list, selecting Remove.

Learn more

  • Watch this video to see how to run Shiny applications in RStudio:

    Figure 4. Video iconRun Shiny applications in RStudio
    This video shows you how to run Shiny applications in RStudio.