Last active
August 5, 2017 22:52
-
-
Save tenkabuto/17934131842d837d81d7a103b47eee37 to your computer and use it in GitHub Desktop.
Crosstab (contingency table) to Dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read in CSV file that's formatted as a Crosstab (empty top left cell, top row contains column names and first column contains row names) | |
# `header = T` pulls column names from first row | |
# `row.names = 1` pulls row names from first column, so starts from 1, not 0 | |
b2009 <- read.csv("20092009 Beer - CrossTab.csv", header = T, row.names = 1) | |
table <- as.table(as.matrix(b2009)) | |
test <- data.frame(table) | |
# Add names to Columns, starting from leftmost column | |
colnames(test) <- c("Beer","Judge","Rating") | |
test[1:37,] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment