#' de_num
#'
#' Convert a number string to the German formatting - converts to character, so be aware!
#' @param x The input, could be a vector or a column
#' @export
de_num <- function(x) {
require(scales)
if(class(x)=='numeric') {
x <- comma(x)
}
x <- gsub('.','^',x,fixed=TRUE)
x <- gsub(',','.',x,fixed=TRUE)
x <- gsub('^',',',x,fixed=TRUE)
return(x)
}
#' undeutsch_num
#'
#' Convert a character string with German numbers back to a numeric format readable in R
#' @param x The input, could be a vector or a column
#' @export
undeutsch_num <- function(x) {
x <- gsub('.','',x,fixed=TRUE)
x <- as.numeric(gsub(',','.',x,fixed=TRUE))
return(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.