Skip to content

Instantly share code, notes, and snippets.

@djhocking
djhocking / dplyr-select-names.R
Last active February 28, 2022 19:08
Select columns by vector of names using dplyr
one <- seq(1:10)
two <- rnorm(10)
three <- runif(10, 1, 2)
four <- -10:-1
df <- data.frame(one, two, three)
df2 <- data.frame(one, two, three, four)
str(df)
@MarkEdmondson1234
MarkEdmondson1234 / dynamicSelectShinyModule.R
Last active November 21, 2020 00:09
Shiny modules for creating dynamic SelectInputs
library(shiny)
#' Safe subset
#'
#' @param df Dataframe
#' @param column One name of column to subset within
#' @param subset Vector of entries in column to subset to
#'
#' If column not in df, returns back the df
safeSubset <- function(df, column, subset){
@nmcc
nmcc / CONSOLAS.md
Last active July 30, 2024 06:42
Install Consolas font on Mac

Download and install the font

  1. Download the Consolas font from http://www.fontpalace.com/font-details/Consolas/
  2. Open Finder and navigate to Downloads directory
  3. Double click the Consolas.ttf file
  4. A dialog box appears displaying the details about the font
  5. Click Install font button

Using Consolas font on IntelliJ IDEA:

  1. Open IDEA Preferences Window (Press Command + ,)
  2. Editor > Colors & Fonts > Font
@DarwinAwardWinner
DarwinAwardWinner / analyze_pkg_usage.R
Last active October 19, 2024 01:59
Script for finding loaded but unused packages in R scripts
#!/usr/bin/env Rscript
suppressPackageStartupMessages({
library(globals)
library(readr)
library(stringr)
library(rex)
library(magrittr)
library(rlang)
library(knitr)
# code to get all stop locations from a GTFS feed and save them as a shapefile
library(tidytransit)
library(sf)
# find your agency's GTFS feed on https://openmobilitydata.org/feeds
gtfs <- read_gtfs("http://kamino.mcts.org/gtfs/google_transit.zip")
stops <- gtfs$stops
stops_sf <- st_as_sf(stops, coords = c("stop_lon", "stop_lat"))