Skip to content

Instantly share code, notes, and snippets.

View fegue's full-sized avatar

Felix Günther fegue

View GitHub Profile
@fegue
fegue / R_libaries_install_missing.R
Last active April 21, 2021 07:14
[Install Maybe] R Script install packages that are not yet on computer #R #Rpackages
### INSTALL ALL LIBRARIES AND DEPENDENCIES #####
# this will only install the packages that are not already installed on your computer i.e. packages won't get updated
libs <- c(
)
## which packages are not yet installed?
libsInstalled <- installed.packages()[,1]
@fegue
fegue / R_libraries_install_on_linux.sh
Last active May 3, 2021 09:23
[R Libraries] Install common R libraries with Linux dependencies #R #linux
#!/bin/bash
# Install common packages; the tidyverse commes with a LOT of dependencies
R --vanilla << EOF
install.packages(c("tidyverse", "data.table", "devtools"), repos = "https://cran.rstudio.com/")
q()
# Install common packages for spatial operations
sudo apt install libgdal-dev gdal-bin libproj-dev libudunits2-dev
R --vanilla << EOF
install.packages(c("rgdal", "rgeos", "sp", "sf", "raster"), repos = "https://cran.rstudio.com/")
@fegue
fegue / no_zero.R
Last active March 12, 2019 11:06
[Tidy Plot Axis - No Zeros] remove leading/trailing zeros on continouse axis in ggplot #R #ggplot
no_zero <- function(x, integer_zero = TRUE, digits = 2) {
x <- round(x, digits = digits)
y <- sprintf(paste0('%.', digits,'f'),x)
y[x > 0 & x < 1] <- sprintf('.%s',x[x > 0 & x < 1]*(10**digits))
y[x > -1 & x < 0] <- sprintf('-.%s',x[x > -1 & x < 0]*(-10**digits))
y <- gsub(pattern = "0", replacement = "", x = y)
if(integer_zero){
y[(x%%1) == 0] <- sprintf("%s", x[(x%%1) == 0])
} else {
y[x == 0] <- '0'
@fegue
fegue / r_ubuntu_20_04.sh
Last active May 10, 2021 07:36 — forked from ElToro1966/r_ubuntu_18_04.sh
[R on Linux] Setup R and RStudio on Ubuntu 20.04 #R #linux
#!/bin/bash
# Add CRAN Repository for an up-to-date R-Version
# https://cran.r-project.org/bin/linux/ubuntu/README.html
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
# Follow instructions to add key
# Install R
sudo apt update
sudo apt install libxml2-dev libssl-dev libcurl4-openssl-dev libopenblas-dev r-base r-base-dev