IMPORTANT NOTE: Support for addins is available only within the most recent release of RStudio (v0.99.878 or later). If you want to try out addins please be sure to download this release.
An addin can be as simple as a function that inserts a commonly used snippet of text, and as complex as a Shiny application that accepts input from the user, and later mutates a document open in RStudio. The sky is the limit!
You might be surprised to know that the Insert %in% addin is implemented entirely with R code. In fact, the R function that made this happen is located here, and its definition is simply:
The rstudioapi package allows you to interact with RStudio directly from the R code you write. You should install a recent (>= v0.5) version of the rstudioapi package to ensure you have access to all of the functions described below:
For addins in particular, a number of methods were added that allow R code to introspect and mutate the contents of a document open in RStudio. These methods are outlined below briefly, but see documentation within the rstudioapi package for more details.
Since addins are just R functions, how does addinexamples let RStudio know what functions are safe to call as addins? This is done through the registration file located at inst/rstudio/addins.dcf. Each addin you register should have the following four fields:
RStudio will automatically discover and register these addins when your package is installed. Note that you can register as many addins as you like within a single addins.dcf file, just be sure to insert a blank line between each addin that is registered.
Interactive addins are invoked by emitting a call to their function directly into the R console. For addins that display user-interface (e.g. using a Shiny application) this enables users to stop/interrupt them.
Shiny gadgets are Shiny applications which can be registered and run as addins. Typically, a Shiny Gadget provides a mechanism for interactively generating code, or modifying a document, but within this realm the possibilities are endless. This article demonstrates how you might create a simple Shiny Gadget, for more complete documentation see the following articles on the Shiny Developer Center:
The server function used for a Shiny Gadget is similar to one as provided for a regular Shiny application, except with the requirement that your application must respond to the done event. For example,
dialogViewer(): Launch your Shiny Gadget as a modal dialog within the RStudio IDE. Use this when your gadget requires a large amount of screen real estate, but is not heavy-weight enough to require a separate window.
browserViewer(): Launch your Shiny gadget in a separate window. Use this for large Shiny gadgets that require a large amount of real estate, and perhaps are more complex than applications that could fit comfortably within an RStudio modal dialog.
R is a popular statistical analysis and machine-learning package that enables data management and includes tests, models, analyses and graphics. RStudio, included in IBM Watson Studio, provides an integrated development environment for working with R scripts.
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.
Sometimes, when you start an RStudio session, you might experience a corrupted RStudio state from a previous session and your session will not start. If this happens, select to reset the workspace at the time you select the RStudio environment and then start the RStudio IDE again. By resetting the workspace, RStudio is started using the default settings with a clean RStudio workspace.
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 files. You can do this by navigating to the directory with the files and clicking More > Set as Working Directory.
Project data assets 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 the project-objectstorage directory in your RStudio Home directory.
Files stored in local storage that are mounted to /home/rstudio. The home directory has a storage limitation of 2 GB and is used to store the RStudio session workspace. Note that you are allocated 2 GB for your home directory storage across all of your projects, irrespective of whether you use RStudio in each project. As a consequence, you should only store R script files and small data files in the home directory. It is not intended for large data files or large generated output. All large data files should be uploaded as project assets, which are mounted to the project-objectstorage directory from where you can access them.
An RStudio environment runtime is always scoped to an environment template and an RStudio session user. Only one RStudio session can be active per Watson Studio user at one time. If you started RStudio in another project, you are asked if you want to stop that session and start a new RStudio session in the context of the current project you're working in.
Runtime usage is calculated by the number of capacity unit hours (CUHs) consumed by the active environment runtime. The CUHs consumed by an active RStudio runtime in a project are billed to the account of the project creator. See Capacity units per hour billing for RStudio.
Remember: The CUH counter continues to increase while the runtime is active so stop the runtime if you aren't using RStudio. If you don't explicitly stop the runtime, it is stopped for you after an idle time of 2 hour. During this idle time, you will continue to consume CUHs for which you are billed. Long compute-intensive jobs are hard stopped after 24 hours.
If you want to run a server in the Amazon cloud, you have to select what system you are going to bootup. This is made easy by a vast array of system images (or AMIs) which pre-pacakge a system ready for you to boot on your own custom virtual server. Many of these are simply base operating system installs, such as Debian or Ubuntu, but others add on pre-configured extra software into the image to reduce time-to-getting-stuff-done! I have created an AMI specifically targeted at R and RStudio Server with the goal of making it a 1 minute job to get going for anyone with an AWS account.
From May 2016 to September 2018 there was experimental support for Julia (and Python). Julia is an exciting new technical computing language which is very high performance. A lot of R programmers may be interested in levereging both languages, so the AMIs included a web interface (Jupyter) which enabled using Julia immediately.
Unfortunately, with the recent package management system changes, I have had difficulties including the lastest Julia release. This is because Jupyter requires all users to have access to IJulia prior to login, meaning a global package set. This was possible in earlier versions of Julia, but at the time of writing, I have been unable to make the same work with the newest Julias. If you would like to see this functionality return, please contribute to this thread at the Julia community where I have detailed the previous solution and current problems.
There are a lot of AMIs to maintain because Amazon have a relatively complicated set of options for running virtual servers. Recently that has simplified so that the only major choice to make is what region you would like to run in, because all instance types now support 64-bit and HVM (the highest performance).
You will then be in and able to use R straight away. It is highly recommended you change the password immediately and an easy means of doing this is explained upon login in the script that is loaded there. However, users who are comfortable with Linux can follow the usual procedure for changing system user passwords via SSH or the Terminal tab within the RStudio interface if they prefer. Advanced users should also note that the rstudio user can use sudo.
Support for setting up Dropbox syncing. The function linkDropbox() makes it easy to link the server to a Dropbox account, so that files and data can be incredibly easily synced in and out. Simply load the package, run the linkDropbox() function and follow the instructions (there may be a pause while everything is setup).
93ddb68554