Skip to content

Instantly share code, notes, and snippets.

@infotroph
Created June 29, 2016 18:35
Show Gist options
  • Save infotroph/5ae87edc624cd58e7b45044a4cd3812b to your computer and use it in GitHub Desktop.
Save infotroph/5ae87edc624cd58e7b45044a4cd3812b to your computer and use it in GitHub Desktop.
library("tidyr")
raw = read.csv("the_data.csv", header=FALSE, colClasses="character")
colnames(raw) = (data.frame(r1=unlist(raw[1,]), r2=unlist(raw[2,]))
%>% mutate(r1=sub("^$", NA, r1))
%>% fill(r1)
%>% transmute(
colname=paste(r1,r2, sep="."))
%>% unlist
)
raw=raw[c(-1, -2),]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment