Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update supported formats lists #151

Merged
merged 1 commit into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions R/export.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@
#' \code{export} supports many file formats. See the documentation for the underlying export functions for optional arguments that can be passed via \code{...}
#'
#' \itemize{
#' \item Tab-separated data (.tsv), using \code{\link[data.table]{fwrite}} or, if \code{fwrite = TRUE}, \code{\link[utils]{write.table}} with \code{row.names = FALSE}.
#' \item Comma-separated data (.csv), using \code{\link[data.table]{fwrite}} or, if \code{fwrite = TRUE}, \code{\link[utils]{write.table}} with \code{row.names = FALSE}.
#' \item Pipe-separated data (.psv), using \code{\link[data.table]{fwrite}} or, if \code{fwrite = TRUE}, \code{\link[utils]{write.table}} with \code{sep = '|'} and \code{row.names = FALSE}.
#' \item Tab-separated data (.tsv), using \code{\link[data.table]{fwrite}} or, if \code{fwrite = TRUE}, \code{\link[utils]{write.table}} with \code{row.names = FALSE}.
#' \item SAS (.sas7bdat), using \code{\link[haven]{write_sas}}.
#' \item SPSS (.sav), using \code{\link[haven]{write_sav}}
#' \item Stata (.dta), using \code{\link[haven]{write_dta}}. Note that variable/column names containing dots (.) are not allowed and will produce an error.
#' \item Excel (.xlsx), using \code{\link[openxlsx]{write.xlsx}}. Use \code{which} to specify a sheet name and \code{overwrite} to decide whether to overwrite an existing file or worksheet (the default) or add the data as a new worksheet (with \code{overwrite = FALSE}). \code{x} can also be a list of data frames; the list entry names are used as sheet names.
#' \item R syntax object (.R), using \code{\link[base]{dput}} (by default) or \code{\link[base]{dump}} (if \code{format = 'dump'}
#' \item Saved R objects (.RData,.rda), using \code{\link[base]{save}}. In this case, \code{x} can be a data frame, a named list of objects, an R environment, or a character vector containing the names of objects if a corresponding \code{envir} argument is specified.
#' \item Serialized R objects (.rds), using \code{\link[base]{saveRDS}}
#' \item "XBASE" database files (.dbf), using \code{\link[foreign]{write.dbf}}
#' \item Weka Attribute-Relation File Format (.arff), using \code{\link[foreign]{write.arff}}
#' \item Fixed-width format data (.fwf), using \code{\link[utils]{write.table}} with \code{row.names = FALSE}, \code{quote = FALSE}, and \code{col.names = FALSE}
#' \item gzip comma-separated data (.csv.gz), using \code{\link[utils]{write.table}} with \code{row.names = FALSE}
#' \item \href{https://github.com/csvy}{CSVY} (CSV with a YAML metadata header) using \code{\link[csvy]{write_csvy}}. The YAML header lines are preceded by R comment symbols (\#) by default; this can be turned off by passing a \code{comment_header = FALSE} argument to \code{export}. Setting \code{fwrite = TRUE} (the default) will rely on \code{\link[data.table]{fwrite}} for much faster export.
#' \item Pipe-separated data (.psv), using \code{\link[data.table]{fwrite}} or, if \code{fwrite = TRUE}, \code{\link[utils]{write.table}} with \code{sep = '|'} and \code{row.names = FALSE}.
#' \item Feather R/Python interchange format (.feather), using \code{feather::write_feather}
#' \item Fast storage (.fst), using \code{\link[fst]{write.fst}}
#' \item Fixed-width format data (.fwf), using \code{\link[utils]{write.table}} with \code{row.names = FALSE}, \code{quote = FALSE}, and \code{col.names = FALSE}
#' \item Serialized R objects (.rds), using \code{\link[base]{saveRDS}}
#' \item Saved R objects (.RData,.rda), using \code{\link[base]{save}}. In this case, \code{x} can be a data frame, a named list of objects, an R environment, or a character vector containing the names of objects if a corresponding \code{envir} argument is specified.
#' \item JSON (.json), using \code{\link[jsonlite]{toJSON}}
#' \item YAML (.yml), using \code{\link[yaml]{as.yaml}}
#' \item Stata (.dta), using \code{\link[haven]{write_dta}}. Note that variable/column names containing dots (.) are not allowed and will produce an error.
#' \item SPSS (.sav), using \code{\link[haven]{write_sav}}
#' \item SAS (.sas7bdat), using \code{\link[haven]{write_sas}}.
#' \item "XBASE" database files (.dbf), using \code{\link[foreign]{write.dbf}}
#' \item Weka Attribute-Relation File Format (.arff), using \code{\link[foreign]{write.arff}}
#' \item R syntax object (.R), using \code{\link[base]{dput}} (by default) or \code{\link[base]{dump}} (if \code{format = 'dump'}
#' \item Matlab (.mat), using \code{\link[rmatio]{write.mat}}
#' \item Excel (.xlsx), using \code{\link[openxlsx]{write.xlsx}}. Use \code{which} to specify a sheet name and \code{overwrite} to decide whether to overwrite an existing file or worksheet (the default) or add the data as a new worksheet (with \code{overwrite = FALSE}). \code{x} can also be a list of data frames; the list entry names are used as sheet names.
#' \item OpenDocument Spreadsheet (.ods), using \code{\link[readODS]{write_ods}}. (Currently only single-sheet exports are supported.)
#' \item XML (.xml), using a custom method based on \code{\link[xml2]{xml_add_child}} to create a simple XML tree and \code{\link[xml2]{write_xml}} to write to disk.
#' \item HTML (.html), using a custom method based on \code{\link[xml2]{xml_add_child}} to create a simple HTML table and \code{\link[xml2]{write_xml}} to write to disk.
#' \item XML (.xml), using a custom method based on \code{\link[xml2]{xml_add_child}} to create a simple XML tree and \code{\link[xml2]{write_xml}} to write to disk.
#' \item YAML (.yml), using \code{\link[yaml]{as.yaml}}
#' \item Clipboard export (on Windows and Mac OS), using \code{\link[utils]{write.table}} with \code{row.names = FALSE}
#' }
#'
Expand Down
39 changes: 20 additions & 19 deletions R/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,37 @@
#' \code{import} supports the following file formats:
#'
#' \itemize{
#' \item Tab-separated data (.tsv), using \code{\link[data.table]{fread}} or, if \code{fread = FALSE}, \code{\link[utils]{read.table}} with \code{row.names = FALSE} and \code{stringsAsFactors = FALSE}
#' \item Comma-separated data (.csv), using \code{\link[data.table]{fread}} or, if \code{fread = FALSE}, \code{\link[utils]{read.table}} with \code{row.names = FALSE} and \code{stringsAsFactors = FALSE}
#' \item gzip comma-separated data (.csv.gz), using \code{\link[utils]{read.table}} with \code{row.names = FALSE} and \code{stringsAsFactors = FALSE}
#' \item \href{https://github.com/csvy}{CSVY} (CSV with a YAML metadata header) using \code{\link[csvy]{read_csvy}}.
#' \item Feather R/Python interchange format (.feather), using \code{feather::read_feather}
#' \item Fast storage (.fst), using \code{\link[fst]{read.fst}}
#' \item Pipe-separated data (.psv), using \code{\link[data.table]{fread}} or, if \code{fread = FALSE}, \code{\link[utils]{read.table}} with \code{sep = '|'}, \code{row.names = FALSE} and \code{stringsAsFactors = FALSE}
#' \item Fixed-width format data (.fwf), using a faster version of \code{\link[utils]{read.fwf}} that requires a \code{widths} argument and by default in rio has \code{stringsAsFactors = FALSE}. If \code{readr = TRUE}, import will be performed using \code{\link[readr]{read_fwf}}, where \code{widths} should be: \code{NULL}, a vector of column widths, or the output of \code{\link[readr]{fwf_empty}}, \code{\link[readr]{fwf_widths}}, or \code{\link[readr]{fwf_positions}}.
#' \item Serialized R objects (.rds), using \code{\link[base]{readRDS}}
#' \item Saved R objects (.RData,.rda), using \code{\link[base]{load}} for single-object .Rdata files. Use \code{which} to specify an object name for multi-object .Rdata files.
#' \item JSON (.json), using \code{\link[jsonlite]{fromJSON}}
#' \item YAML (.yml), using \code{\link[yaml]{yaml.load}}
#' \item Stata (.dta), using \code{\link[haven]{read_dta}}. If \code{haven = FALSE}, \code{\link[foreign]{read.dta}} can be used.
#' \item Tab-separated data (.tsv), using \code{\link[data.table]{fread}} or, if \code{fread = FALSE}, \code{\link[utils]{read.table}} with \code{row.names = FALSE} and \code{stringsAsFactors = FALSE}
#' \item SAS (.sas7bdat), using \code{\link[haven]{read_sas}}.
#' \item SPSS (.sav), using \code{\link[haven]{read_sav}}. If \code{haven = FALSE}, \code{\link[foreign]{read.spss}} can be used.
#' \item Stata (.dta), using \code{\link[haven]{read_dta}}. If \code{haven = FALSE}, \code{\link[foreign]{read.dta}} can be used.
#' \item SAS XPORT (.xpt), using \code{\link[foreign]{read.xport}}.
#' \item SPSS Portable Files (.por), using \code{\link[haven]{read_por}}.
#' \item "XBASE" database files (.dbf), using \code{\link[foreign]{read.dbf}}
#' \item Weka Attribute-Relation File Format (.arff), using \code{\link[foreign]{read.arff}}
#' \item R syntax object (.R), using \code{\link[base]{dget}}
#' \item Matlab (.mat), using \code{\link[rmatio]{read.mat}}
#' \item Excel (.xls and .xlsx), using \code{\link[readxl]{read_excel}}. If \code{readxl = FALSE}, \code{\link[openxlsx]{read.xlsx}} can be used. Use \code{which} to specify a sheet number.
#' \item SAS (.sas7bdat) and SAS XPORT (.xpt), using \code{\link[haven]{read_sas}} and \code{\link[foreign]{read.xport}}.
#' \item Minitab (.mtp), using \code{\link[foreign]{read.mtp}}
#' \item R syntax object (.R), using \code{\link[base]{dget}}
#' \item Saved R objects (.RData,.rda), using \code{\link[base]{load}} for single-object .Rdata files. Use \code{which} to specify an object name for multi-object .Rdata files.
#' \item Serialized R objects (.rds), using \code{\link[base]{readRDS}}
#' \item Epiinfo (.rec), using \code{\link[foreign]{read.epiinfo}}
#' \item Minitab (.mtp), using \code{\link[foreign]{read.mtp}}
#' \item Systat (.syd), using \code{\link[foreign]{read.systat}}
#' \item "XBASE" database files (.dbf), using \code{\link[foreign]{read.dbf}}
#' \item Weka Attribute-Relation File Format (.arff), using \code{\link[foreign]{read.arff}}
#' \item Data Interchange Format (.dif), using \code{\link[utils]{read.DIF}}
#' \item Fortran data (no recognized extension), using \code{\link[utils]{read.fortran}}
#' \item Fixed-width format data (.fwf), using a faster version of \code{\link[utils]{read.fwf}} that requires a \code{widths} argument and by default in rio has \code{stringsAsFactors = FALSE}. If \code{readr = TRUE}, import will be performed using \code{\link[readr]{read_fwf}}, where \code{widths} should be: \code{NULL}, a vector of column widths, or the output of \code{\link[readr]{fwf_empty}}, \code{\link[readr]{fwf_widths}}, or \code{\link[readr]{fwf_positions}}.
#' \item gzip comma-separated data (.csv.gz), using \code{\link[utils]{read.table}} with \code{row.names = FALSE} and \code{stringsAsFactors = FALSE}
#' \item \href{https://github.com/csvy}{CSVY} (CSV with a YAML metadata header) using \code{\link[csvy]{read_csvy}}.
#' \item Feather R/Python interchange format (.feather), using \code{feather::read_feather}
#' \item Fast storage (.fst), using \code{\link[fst]{read.fst}}
#' \item JSON (.json), using \code{\link[jsonlite]{fromJSON}}
#' \item Matlab (.mat), using \code{\link[rmatio]{read.mat}}
#' \item OpenDocument Spreadsheet (.ods), using \code{\link[readODS]{read_ods}}. Use \code{which} to specify a sheet number.
#' \item Shallow XML documents (.xml), using \code{\link[xml2]{read_xml}}. The data structure will only be read correctly if the XML file can be converted to a list via \code{\link[xml2]{as_list}}.
#' \item Single-table HTML documents (.html), using \code{\link[xml2]{read_html}}. The data structure will only be read correctly if the HTML file can be converted to a list via \code{\link[xml2]{as_list}}.
#' \item Shallow XML documents (.xml), using \code{\link[xml2]{read_xml}}. The data structure will only be read correctly if the XML file can be converted to a list via \code{\link[xml2]{as_list}}.
#' \item YAML (.yml), using \code{\link[yaml]{yaml.load}}
#' \item Clipboard import (on Windows and Mac OS), using \code{\link[utils]{read.table}} with \code{row.names = FALSE}
#' \item Fortran data (no recognized extension), using \code{\link[utils]{read.fortran}}
#' \item Google Sheets, as Comma-separated data (.csv)
#' }
#'
Expand Down
Loading