Skip to content

Instantly share code, notes, and snippets.

@tonyfischetti
Created July 3, 2015 13:05
Show Gist options
  • Save tonyfischetti/0d27b9ab414ad5766339 to your computer and use it in GitHub Desktop.
Save tonyfischetti/0d27b9ab414ad5766339 to your computer and use it in GitHub Desktop.
Column duplication
#!/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