#' Replaces commas by semicolons inside of a file
#'
#' Replaces all commas by semicolons in a file and overwrites the file. The
#' function is actually capable of replacing other strings too, but that is not
#' the standard.
#'
#' @param file the file to modify.
#' @param pattern the string to replace.
#' @param replacement the replacement.
#' @keywords substitute, replace
#' @export
#' @examples
#' table <- cbind(1:10, LETTERS[1:10])
#' # this will create a file in the working dir
#' write.csv(table, file = "comma_to_semicolon_example.csv")
#' read.csv("comma_to_semicolon_example.csv")
#' comma_to_semicolon("comma_to_semicolon_example.csv")
#' read.csv("comma_to_semicolon_example.csv")
comma_to_semicolon <-
function(file,
pattern = ",",
replacement = ";") {
corrected <- gsub(pattern, replacement, readLines(file))
writeLines(corrected, con = file)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.