Skip to content

Instantly share code, notes, and snippets.

View dschneiderch's full-sized avatar

Dominik Schneider dschneiderch

View GitHub Profile
@jlacko
jlacko / rstudio-init-script.R
Last active July 7, 2021 21:35
Init script for new RStudio installation, promoting best practices
# make certain jsonlite is available
if(!require(jsonlite, quietly = TRUE)) {
install.packages("jsonlite")
library(jsonlite)
}
# get the path to settings file
path <- if (Sys.info()[["sysname"]] == "Windows") {
paste0(Sys.getenv('APPDATA'), "\\RStudio\\rstudio-prefs.json")
} else {
library(tidyverse)
by_species <- iris %>%
group_by(Species) %>%
nest()
specific_models <- tibble(
Species = unique(iris$Species),
model = list(function(d) lm(Sepal.Length ~ Petal.Width + Petal.Length, d),
function(d) lm(Sepal.Length ~ Petal.Width, d),
@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active September 24, 2024 04:20
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

@timofei7
timofei7 / geog54_homebrew
Last active July 18, 2017 08:17
homebrew install software for GEOG54 (may need babysitting)
#install homebrew
# homebrew (from http://brew.sh) is an opensource software package manager for os x
# very much awesome
# installs into /usr/local so you may want to: mv /usr/local /usr/local.old beforehand
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
# tap extra geog related formulas
brew tap dakcarto/osgeo4mac
brew tap homebrew/science