Skip to content

Instantly share code, notes, and snippets.

@benilton
Created November 28, 2023 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benilton/176303d56ed9b85a13dda7759f171179 to your computer and use it in GitHub Desktop.
Save benilton/176303d56ed9b85a13dda7759f171179 to your computer and use it in GitHub Desktop.
Configura Google Colab para R
## Instalação r2u
shell_call <- function(command, ...) {
result <- system(command, intern = TRUE, ...)
cat(paste0(result, collapse = "\n"))
}
download.file("https://github.com/eddelbuettel/r2u/raw/master/inst/scripts/add_cranapt_jammy.sh",
"add_cranapt_jammy.sh")
Sys.chmod("add_cranapt_jammy.sh", "0755")
shell_call("./add_cranapt_jammy.sh")
bspm::enable()
options(bspm.version.check=FALSE)
shell_call("rm add_cranapt_jammy.sh")
## Preparando acesso ao Google Drive
loadPackages = function(pkgs){
myrequire = function(...){
suppressWarnings(suppressMessages(suppressPackageStartupMessages(require(...))))
}
ok = sapply(pkgs, require, character.only=TRUE, quietly=TRUE)
if (!all(ok)){
message("There are missing packages: ", paste(pkgs[!ok], collapse=", "))
install.packages(pkgs[!ok])
loadPackages(pkgs[!ok])
}
}
loadPackages(c("googledrive", "httpuv", "R.utils", "httr", "RSQLite", "tidyverse"))
my_check = function() TRUE
reassignInPackage("is_interactive", pkgName="httr", my_check)
options(rlang_interactive=TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment