Skip to content

Instantly share code, notes, and snippets.

View wmcraver's full-sized avatar
🌵
Learning some new things

Mitch wmcraver

🌵
Learning some new things
View GitHub Profile
@wmcraver
wmcraver / CheckURLs.R
Last active September 28, 2016 22:41
library(httr)
library(stringr)
dat = read.csv("fileWithURLs.csv", stringsAsFactors = F)
---------------- for loop to get results ----------------
for (i in 1:nrow(dat)) {
a = GET(dat$Current.Forward[i])
dat$URL[i] = a$url
@wmcraver
wmcraver / InstallPackages.R
Last active September 1, 2016 21:34
Checks for package installation. If the package does not exist, it installs them.
needed = c("lubridate", "dplyr", "data.table", "stringr")
is.installed = function(pkg){
is.element(pkg, installed.packages()[,1])
}
# For loop to run through each of the packages
for (p in 1:length(needed)){
ifelse(!is.installed(needed[p]), install.packages(needed[p], dependencies = T), print(paste(needed[p], " is already installed", sep = "")))
}
@wmcraver
wmcraver / ShowYourCard.R
Last active September 1, 2016 21:34
Used to extract analytics traffic from Page Category CSV files. Files are by day and are read in, filtered for specific information and then stored in a data frame.
needed = c("lubridate", "dplyr", "data.table", "stringr")
is.installed <- function(pkg){is.element(pkg, installed.packages()[,1])}
for (p in 1:length(needed)){ifelse(!is.installed(needed[p]), install.packages(needed[p], dependencies = T),print(paste(needed[p], " is already installed", sep = "")))}
library(lubridate)
library(dplyr)
library(data.table) #used for the %like% function
library(stringr)
@wmcraver
wmcraver / haiku.R
Last active August 20, 2016 22:11 — forked from friggeri/haiku
random heroku-like name generator in R
haiku = function () {
adjs = c(
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
"summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
"patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
"billowing", "broken", "cold", "damp", "falling", "frosty", "green",
"long", "late", "lingering", "bold", "little", "morning", "muddy", "old",
"red", "rough", "still", "small", "sparkling", "throbbing", "shy",
"wandering", "withered", "wild", "black", "young", "holy", "solitary",
"fragrant", "aged", "snowy", "proud", "floral", "restless", "divine",