Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R] Update dependencies for datascience build #65

Closed
wants to merge 12 commits into from
8 changes: 8 additions & 0 deletions r/datascience/Aptfile
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
libcurl4-openssl-dev
libfontconfig1-dev
libfribidi-dev
libgdal-dev
libharfbuzz-dev
libssl-dev
libxml2-dev
unixodbc
unixodbc-dev
30 changes: 29 additions & 1 deletion r/datascience/install_packages.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
packages <- readLines("/tmp/requirements.R")
install.packages(packages, repos='http://cran.us.r-project.org')

# Function to check if a package is installed
is_package_installed <- function(package) {
return(package %in% rownames(installed.packages()))
}

# Install packages with error handling
for (pkg in packages) {
# Skip if the package has a `#` in front
if (substr(pkg, 1, 1) == "#") {
next
}
tryCatch({
# Attempt to install the package
install.packages(pkg, repos='http://cran.us.r-project.org')

# Check if installation was successful, otherwise raise error
if (!is_package_installed(pkg)) {
stop(paste("⛔ Installation of package", pkg, "failed."))
} else {
message(paste("✅ Package", pkg, "installed successfully."))
}
},
error = function(e) {
# Handle errors: print error message
stop(paste("🔥 Error installing package", pkg, ":", e$message))
}
)
}
19 changes: 13 additions & 6 deletions r/datascience/requirements.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# *** If you add any packages to this file, be sure to test their installation in the dockerfile before the `RUN R -e "source('/tmp/install_packages.R')"` line. ***
# e.g. `RUN R -e "install.packages('NEW_PACKAGE', repos = 'http://cran.us.r-project.org')"
# This should make it easier to determine if any other dependencies are required and should result in less time spent waiting for the docker build to (possibly) fail.
arrow
caret
crayon
# ragg/pkgdown are required for devtools but not installed automatically
ragg
remotes
pkgdown
devtools
dplyr
e1071
Expand All @@ -11,13 +18,13 @@ hexbin
htmltools
htmlwidgets
nycflights13
randomforest
rcurl
rgdal
odbc
randomForest
RCurl
# rgdal (removed Oct 2023: https://cran.r-project.org/web/packages/rgdal/index.html)
rmarkdown
rodbc
rsqlite
RODBC
RSQLite
shiny
tidymodels
tidyverse
unixodbc
Loading