R transformation reference
Lookup reference for R transformations in Keboola — runtime environment and version, limits, file locations, packages, CSV format, row-index handling, warnings-as-errors, backend sizes, and logging.
Reference material for R transformations. To create and run one, see the how-to.
Environment
Section titled “Environment”The R script runs in an isolated environment. The current R version is 4.4.1; you can switch a configuration to other available versions. Version updates are announced in the changelog.
Limits
Section titled “Limits”| Resource | Limit |
|---|---|
| Memory | 16 GB |
| Max running time | 6 hours |
| CPU | Equivalent of two 2.3 GHz processors |
File locations
Section titled “File locations”- The script is compiled to
/data/script.R. - Mapped input/output tables: relative
in/tables/file.csv,out/tables/file.csvor absolute under/data/. - Downloaded files:
in/files/(or/data/in/files/). - Temporary files:
/tmp/. Do not use/data/for files you don’t want exchanged with Keboola.
See the full Common Interface specification.
Packages
Section titled “Packages”R transformations can use any package on CRAN. List a package’s name in the package section to load and install it (with dependencies) automatically — library() is then not needed. The latest versions are installed.
Some packages are preinstalled (with dependencies); for an authoritative list use installed.packages(). Adding a preinstalled package explicitly does no harm but slows startup due to forced re-installation.
CSV format
Section titled “CSV format”Input tables arrive as CSV and can be read with standard R functions. If R misreads the format, specify it explicitly:
data <- read.csv("in/tables/in.csv", sep=",", quote="\"")Row index in output tables
Section titled “Row index in output tables”Do not write the row index — use row.names=FALSE. The row index creates an unnamed column that cannot be imported to Storage.
write.csv(data, file="out/tables/out.csv", row.names=FALSE)If the row names hold real data, convert them to a column first:
df <- data.frame(first = c('a', 'b'), second = c('x', 'y'))data <- cbind(rownames(df), df)write.csv(data, file="/data/out/tables/out.csv", row.names=FALSE)Warnings are errors
Section titled “Warnings are errors”The environment converts all warnings to errors, which fail the transformation. To deliberately ignore warnings from a piece of code, wrap it in tryCatch:
tryCatch({ ... some code ... },warning = function(w) {})Logging and events
Section titled “Logging and events”Print informational/debug messages by printing to stdout/stderr. The internally available app$logInfo and app$logError functions record the precise server time of an event (the standard job-event timestamp is when the event was received, converted to local time):
print('doing something')write('error message', stderr())app$logInfo("information")app$logError("error")Backend sizes (dynamic backends)
Section titled “Backend sizes (dynamic backends)”A larger backend allocates more resources for long or heavy transformations. Available sizes:
| Size | |
|---|---|
| XSmall | |
| Small | Default |
| Medium | |
| Large |
Scaling up impacts time-credit consumption. Dynamic backends are not available on the Free Plan (Pay As You Go).