Skip to content

Instantly share code, notes, and snippets.

@dpritchard
dpritchard / ipak.R
Last active August 7, 2016 23:01 — forked from stevenworthington/ipak.R
Install and (optionally) load multiple R packages at once
# ipak function: install and load multiple R packages.
# Check to see if packages are installed. Install them if they are not.
# Optionally, load them into the R session.
ipak <- function(pkg, load = FALSE){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg)) {
install.packages(new.pkg, dependencies = TRUE)
}
update.packages(ask = FALSE)
@dpritchard
dpritchard / exploring_tbl_df.R
Last active August 25, 2015 22:43
Figuring out [.tbl_df
library(dplyr)
# packageVersion("dplyr")
# [1] ‘0.4.2.9002’
## This also applies to readxl... Others that use dplyr?
df <- data.frame("Char" = c("A", "Char", "Vector"), stringsAsFactors = FALSE) # Ye oldy oldschool
dt <- data_frame("Char" = c("A", "Char", "Vector")) # An enhanced dataframe
str(df) # just data.frame
str(dt) # tbl_df, tbl and data.frame