Created
July 3, 2015 13:05
-
-
Save tonyfischetti/0d27b9ab414ad5766339 to your computer and use it in GitHub Desktop.
Column duplication
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
#!/usr/bin/Rscript --vanilla | |
rm(list=ls()) | |
options(stringsAsFactors=FALSE) | |
# libraries | |
library(dplyr) | |
library(magrittr) | |
library(assertr) | |
test <- read.csv("./test.csv", stringsAsFactors=FALSE) | |
(names(test)) | |
# [1] "colour" "count" "double" "square" "double.1" | |
any(duplicated(t(test))) | |
test %>% | |
t %>% # transposes the data frame | |
duplicated %>% # returns BOOL is each row (column) is duplicated | |
any # will return TRUE is any bool is TRUE | |
# with assertr | |
test %>% | |
verify(!any(duplicated(t(.)))) %>% | |
head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment