How-to | Edit Dataiku recipes in RStudio#

Watch the video

Though 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.

Note

This method can edit existing recipes and plugin files on the Dataiku instance, but cannot create new recipes or files.

Prerequisites#

  • You should work through the R in Dataiku tutorial, or otherwise have a project with an available R recipe.

  • Access to a Dataiku instance with the R integration installed.

  • Access to RStudio.

  • A personal API key to the Dataiku instance.

Install the Dataiku R package#

  1. Within RStudio, run the following code to install the dataiku package.

    install.packages("<URL_Dataiku_instance>/public/packages/dataiku_current.tar.gz", repos=NULL)
    
  2. 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 replace URL_Dataiku_instance with https://localhost:11500.

    Warning

    The URL will begin with either http or https, depending on how the instance was set up and whether a secure protocol was used

  3. 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#

  1. From the Add-ins menu, choose Dataiku: Setup DSS instance. This opens a dialog where you manage connections to Dataiku instances.

  2. 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.

  3. Select this as your active connection.

  4. Click Save.

Edit a Dataiku recipe#

  1. Open a new R Script.

  2. From the Add-ins menu, choose Dataiku: download R recipe code.

  3. Choose the project key of a project with an R recipe; for example, DKU_TUTORIAL_R if you completed the R and Dataiku course.

  4. Choose the recipe you want to edit from list; for example, compute_orders_by_customer.

  5. Click Download.

Get recipe content dialog from the Dataiku add-in for RStudio

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:

  1. Choose Dataiku: save R recipe code from the Add-ins menu.

  2. Click Send to DSS.

This overwrites any edits made in the meantime on the Dataiku instance.