Civis Platform supports Jupyter notebooks in R and Python. This is a walkthrough of how to use R notebooks in Platform.
Civis has an open-source R API Client that allows users to interact with Platform from R scripts, Notebooks, or from their local R console. While you are able to write code that does not use the R API Client, we recommend using it to streamline your workflows.
To create a new R notebook, select "Jupyter R". To upload an existing notebook, select "R" as the notebook language and choose your desired file.
Notebooks Settings
After choosing R as your desired language, you have the option to configure your notebook's settings before running any code.
The above shows the default configuration for an R notebook. To see which packages are already loaded in the notebook, click "View Packages". If you would like to use a package that is not on that list, please contact support@civisanalytics.com to discuss setting up a custom docker image.
When you are ready to start your notebook, click 'Start Server' (note that this may take several minutes).
Jupyter has its own help documentation--for a tutorial on how to use Jupyter notebooks, go to the 'Help' tab and select 'User Interface Tutorial'.
Once you have finished using your notebook, you MUST save it and shut down the server. If you do not save the notebook before shutting down the server, all changes will be lost. If you do not shut down the notebook before exiting, it will continue to run and consume computing resources. If a notebook is idle (i.e. no processes in the notebook are running) for a continuous 3 hours, the notebook will automatically shut down.
Add a Credential
To add a credential to your notebook, select a credential that you have already stored in Platform from the dropdown, or click 'Add a New Credential'. The credential will be stored as two environment variables: 'credentialname_USERNAME' and 'credentialname_PASSWORD'. For example, to access a credential called 'tester', you would run the following commands.
Sys.setenv("username" = Sys.getenv("TESTER_USERNAME"), "password" = Sys.getenv("TESTER_PASSWORD"))
Comments
0 comments
Please sign in to leave a comment.