#'@title write data.frames to file in common formats.
#'@description easy wrappers to turn objects into quoted TSV or CSVs or .RData files.
#'
#'@param df the data.frame you want to write out.
#'
#'@param file_path the path to the file to write it to.
#'
#'@name writers
#'@rdname writers
#'@export
write_csv <- function(df, file_path){
write_file(df, file_path, sep = ",")
}
#'@rdname writers
#'@export
write_tsv <- function(df, file_path){
write_file(df, file_path, sep = "\t")
}
#'@rdname writers
#'@export
write_rdata <- function(df, file_path){
save(x, file = filename)
}
write_file <- function(df, file_path, sep){
if(file.exists(file_path)){
col_names <- FALSE
} else {
col_names <- TRUE
}
write.table(x = df, file = file_path, append = TRUE, quote = TRUE, sep = sep,
row.names = FALSE, col.names = col_names)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.