This function allows you to write a CrunchDataset to a .csv or SPSS .sav file.
CrunchDataset, which may have been subsetted with a filter expression on the rows and a selection of variables on the columns.
character local filename to write to
character export format: currently supported values are "csv" and "spss" (and experimental support for "parquet").
character: export categorical values to CSV as category "name" (default) or "id". Ignored by the SPSS exporter.
Similar to the argument in utils::write.table()
, 'na'
lets you control how missing values are written into the CSV file.
Supported values are:
NULL
, the default, which means that
categorical variables will have the category name or id as the value, and
numeric, text, and datetime variables will have the missing reason string;
A string to use for missing values.
""
means that empty cells will be written for missing values for all types.
For SPSS export, which Crunch metadata field should be used as variable labels? Default is "name", but "description" is another valid value.
logical: should hidden variables be included? (default: FALSE
)
additional options. See the API documentation. Currently supported
boolean options include 'include_personal' for personal variables (default:
FALSE
) and 'prefix_subvariables' for SPSS format: whether to include
the array variable's name in each of its subvariables "varlabels" (default:
FALSE
).
(for write.csv) CrunchDataset, which may have been subsetted with a filter expression on the rows and a selection of variables on the columns.
Invisibly, file
.
if (FALSE) {
csv_file <- exportDataset(ds, "data.csv")
data <- read.csv(csv_file)
# parquet will likely read more quickly and be a smaller download size
parquet_file <- exportDataset(ds, "data.parquet")
# data <- arrow::read_parquet(parquet_file) # The arrow package can read parquet files
}