Skip to content

Instantly share code, notes, and snippets.

View RobertMyles's full-sized avatar
👽

Robert Myles McDonnell RobertMyles

👽
View GitHub Profile
library(ggplot2)
library(scales)
library(tidyr)
library(dplyr)
rm(list=ls())
df <- structure(list(Animal = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L),
.Label = c("Buffalo", "Goat", "Sheep"),
class = "factor"),
Texture = structure(c(4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 2L, 1L, 1L, 4L, 3L, 4L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L),
.Label = c("Hard", "Semi-Hard", "Semi-Soft", "Soft"),
@RobertMyles
RobertMyles / Load-Multiple-R-Packages.R
Created July 8, 2016 19:19
Load multiple packages at the same time in R
# library() or require() only load one package at a time
# but...
Packages <- c("dplyr", "ggplot2", "rstan", "readr")
lapply(Packages, library, character.only = TRUE)
# this loads as many as you put in 'Packages'. They need to be installed first, of course.
@RobertMyles
RobertMyles / LostPackages.R
Last active January 10, 2017 19:23
Updated R today and realized that I lost a load of packages that I had installed previously. Instead of re-installing them one by one, I just did this (it works for Mac OS, it'll be slightly different on Windows):
Old_packList <- as.list(installed.packages("/Library/Frameworks/R.framework/Versions/3.2/Resources/library"))
# here, my R version was 3.2. Change it for the R version you want the packages from!
Old <- as.character(Old_packList)
install.packages(Old)