Created
November 28, 2023 01:46
-
-
Save benilton/176303d56ed9b85a13dda7759f171179 to your computer and use it in GitHub Desktop.
Configura Google Colab para R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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