Submit your innovative use case or inspiring success story to the 2023 Dataiku Frontrunner Awards! LET'S GO

dkuSourceLibR() in Rmarkdown report error

Level 1
dkuSourceLibR() in Rmarkdown report error


Is there a way to import custom libraries in RMarkdown report?
In R code recipe or in notebooks I can use dkuSourceLibR("name_of_library.R") but it results in an error in RMarkdown.

library(dataiku) is correctly imported at the beginning of the report.



0 Kudos
1 Reply

Hi @AndriaM,


Importing custom libraries in R Markdown Report using dkuSourceLibR() is not working if your DSS instance has UIF enabled. 

A possible option is to add the R files to a managed folder, then use dkuManagedFolderPath() to read the file:

managed_folder_path <- dkuManagedFolderPath("folder_ID")
test <- paste0(managed_folder_path, "/", "test.R")


In the case that the manage folder is not on the local file system, you could use dkuManagedFolderDownloadPath to read the file from the managed folder:

# Read file
rfile <- dkuManagedFolderDownloadPath(folder, "test.R", as = "raw")
tmp <- tempfile("tmp",fileext=".R")
tmp_file <- file(tmp, "wb")
writeBin(rfile, tmp_file)


0 Kudos