#' Clean columns to make better tables
#'
#' @param x A data.frame object
#' @param ... Columns to clean
#' @param arrange Whether data should be sorted by column values
#'
#' @return
#' @export
#'
#' @examples
clean_cols <- function(x, ..., arrange = F){
colv = quos(...)
x <- x %>%
mutate_at(vars(!!!colv),as.character) # make sure columns are characters
if(arrange){
x <- x %>% arrange(!!!colv) # Ensure right order of columns
}
for(ii in rev(seq_along(colv))){
indx = duplicated(select(x, !!!colv[ii:1]))
x <- x %>% mutate_at(vars(!!colv[[ii]]), funs(ifelse(indx, '', .)))
}
return(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.