How-to | Edit Dataiku recipes in RStudio#
Watch the video
Although Jupyter notebooks are integrated into the Dataiku interface, many R developers use RStudio. From within RStudio, you can:
Install the
dataiku
package.Connect to an existing Dataiku instance.
Pull code from an R code recipe into RStudio.
Edit the code in RStudio.
Save the code back to the R recipe.
Important
This method can edit existing recipes and plugin files on the Dataiku instance, but cannot create new recipes or files.
Prerequisites#
Access to an instance of Dataiku 12+ with the R integration installed. To get started:
Dataiku Cloud users should consult Reference | Work with R in Dataiku Cloud.
Self-managed users should consult the reference documentation on the R integration.
Access to RStudio.
A personal API key to the Dataiku instance.
A project with an available R recipe. See Tutorial | Dataiku for R users for an example.
Install the Dataiku R package#
Within RStudio, run the following code to install the
dataiku
package.install.packages("<URL_Dataiku_instance>/public/packages/dataiku_current.tar.gz", repos=NULL)
Replace
URL_Dataiku_instance
with the URL to a Dataiku instance; for example, if the instance is using a secure protocol on localhost and listening on port 11500, then replaceURL_Dataiku_instance
withhttps://localhost:11500
.Warning
The URL will begin with either
http
orhttps
, depending on how the instance was set up and whether a secure protocol was used.To install the
dataiku
package, you may need to install some dependencies. Follow RStudio’s (Posit’s) instructions for managing R packages.
The dataiku
package provides add-ins for connecting to a Dataiku instance and managing R recipes on the instance.
Connect to a Dataiku instance#
From the Add-ins menu, choose Dataiku: Setup DSS instance. This opens a dialog where you manage connections to Dataiku instances.
Click +Connect to Another DSS Instance and fill out the following information:
Name. Give the connection a descriptive name.
URL. Provide the URL to your Dataiku instance; e.g. for the instance above
https://localhost:11500
.API Key This is the secret of your Personal API key.
Select this as your active connection.
Click Save.
Edit a Dataiku recipe#
Open a new R script.
From the Add-ins menu, choose Dataiku: download R recipe code.
Choose the project key of a project with an R recipe.
Choose the recipe you want to edit from the list.
Click Download.
The code of the Dataiku R recipe is downloaded into the R script in RStudio. You can run the code like any other R script in RStudio. With the dataiku
package installed, the dkuReadDataset()
function causes RStudio to use the Dataiku API to pull the Dataiku dataset from the server and into a local R dataframe. Other dataiku
package functions likewise use the Dataiku API.
The exception is that you cannot write from RStudio to a Dataiku dataset. You need to save any changes you’ve made to the code back to the Dataiku recipe, and then run the recipe within Dataiku.
Note
You cannot create a new Dataiku R recipe through RStudio using these add-ins; the R recipe must already exist.
Save changes to a recipe#
Changes made in RStudio are made to the recipe in Dataiku when you:
Choose Dataiku: save R recipe code from the Add-ins menu.
Click Send to DSS.
This overwrites any edits made in the meantime on the Dataiku instance.