Skip to content

Instantly share code, notes, and snippets.

Working from home

Tom Bush tomfbush

Working from home
View GitHub Profile
tomfbush / clean.r
Created Nov 22, 2018
Clean a specific column
View clean.r
# function to substitute matching string and everything after it with nothing
# note leading space if that applies to your dataset
removeCrap <- function(crapThing) {
gsub(" (0|[1-9][0-9]*)\ ?(GB).*$", "", crapThing)
# load data from csv into a dataframe
d <- read.csv("input.csv", sep = ",")
# display a few rows of the dataframe 'd'