dkuSourceLibR() in Rmarkdown report error

Solved!
AndriaM
Level 1
dkuSourceLibR() in Rmarkdown report error

Hello,

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.

 

Thanks.

0 Kudos
1 Solution
CatalinaS
Dataiker

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)
close(tmp_file)

 

View solution in original post

1 Reply
CatalinaS
Dataiker

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)
close(tmp_file)