
Get R Script or RDS Object from improve Repository
getR.RdRetrieves an R script (.R) or R data object (.rds) from the improve repository
and returns metadata including the local file path. The file is downloaded but
not loaded into memory - use sourceR() to execute scripts or readRDS()
on the returned path to load RDS objects.
Usage
getR(ident, from = pwd(), addAsLink = TRUE, caption = "", description = "")Arguments
- ident
Path, resource ID, or entity ID of the R file. Can be a relative path (from current step), absolute path, or improve identifier
- from
Root path for resolving relative paths. Defaults to
pwd()(current step location)- addAsLink
Logical. If
TRUE, creates a link in the inventory for provenance tracking. UseimproveClean()at workflow end to clean up links- caption
Custom caption text. If empty, defaults to entityID and lastModified timestamp
- description
Custom description text. If empty, defaults to filename
Value
A data frame with the following columns:
- caption
Character. Source information including entity version ID and last modified timestamp
- path
Character. Local file system path to the downloaded R file. Use this with
source()orreadRDS()- entityId
Character. Entity identifier on improve server
- name
Character. Filename of the R script or RDS object
- description
Character. Description text (defaults to filename)
- resource
List. Complete resource metadata from improve server (29 fields)
Details
Unlike getData() which loads data into memory, getR() only downloads
the R file and returns its metadata. The file is cached locally at the path specified
in the path column.
Common workflows:
For R scripts: Use
sourceR()to execute, orsource(result$path)For RDS objects: Use
readRDS(result$path)to load the objectFor metadata only: Access
result$entityId,result$name, etc.
See also
sourceR for executing R scripts directly,
getData for loading data tables,
improveInit for initializing R modules
Examples
if (FALSE) { # \dontrun{
# Get R script metadata
script_info <- getR("analysis/prepare_data.R")
script_path <- script_info$path
# Load and execute the script
source(script_path)
# Or use sourceR() helper (automatically sources)
sourceR("analysis/prepare_data.R")
# Get RDS object
model_info <- getR("models/final_model.rds")
model <- readRDS(model_info$path)
} # }