sum_na <- function(x) sum(x,na.rm=T)
printf <- function(...) cat(sprintf(...))
duplicated_id <- function(...) duplicated(...) | duplicated(...,fromLast = T)
perc <- function(x) round(x*100/sum(x),1)
perc_sign<- function(x) paste0(round(x*100/sum(x),1),"%")
money <- function(x) paste0("$", formatC(as.numeric(x), format="f", digits=1, big.mark=","))
dir_create <- function(kiddir,momdir="") if (!file.exists(paste0(momdir,kiddir))) dir.create(file.path(momdir, kiddir))
to_m <- function(x) round(x/1e6,1)
to_month <- function(date) as.Date(paste(year(date),month(date),"01",sep="-"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.