Write a data table to local file directory
Arguments
- dat
Name of data frame in working environment to save to file.
- project
String, project name.
- path
String, path or connection to write to. If left empty, the file will be written to the dat folder in the project directory.
- file_type
String, the type of file to write to. Options include
"csv"
,"txt"
(tab-separated text file),"xlsx"
(excel),"rdata"
,"json"
,"stata"
,"spss"
,"sas"
, and"matlab"
.- ...
Additional arguments passed to writing function. See "details" for the list of functions.
Details
Leave path = NULL
to save dat
to the data
folder in the
project
directory
See write.table
for csv and tab-separated files,
save
for R data files,
write.xlsx
,
read_json
for json files,
st_write
for geojson files,
read_dta
for Stata files,
read_spss
for SPSS files,
read_sas
for SAS files, and
writeMat
for Matlab files, and
st_write
for shape files.
Examples
if (FALSE) {
# Save to the default data folder in project directory
write_dat(pollockMainDataTable, type = "csv", "pollock")
# Save to defined directory location
write_dat(pollockMainDataTable, path = "C://data/pollock_dataset.csv",
type = "csv", "pollock")
# Save shape file
write_dat(ST6, path = "C://data//ST6.shp", type = "shp", project = 'Pollock')
}