write_odf: Write R data frame to the Open Data Format.

View source: R/write_odf.R

write_odfR Documentation

Write R data frame to the Open Data Format.

Description

Export data from an R data frame to a ZIP file that stores the data as Open Data Format.

Usage

write_odf(
  x,
  file,
  languages = "all",
  export_data = TRUE,
  verbose = TRUE,
  compression_level = 5,
  odf_version = "1.1.0"
)

Arguments

x

R data frame (df) to be writtem.

file

Path to ZIP file or name of zip file to save the odf-dataset in the working directory.

languages

Select the language in which the descriptions and labels of the data will be exported

  • By default all available language variants are exported (languages = "all").

  • You can also choose to export only the default language (languages = "default"),

  • Or only the current language (languages = "current"),

  • or you can select the language by language code, e.g. languages = "en".

export_data

Choose, if you want to export the file that holds the data (data.csv).Default is TRUE.

verbose

Display more messages.

compression_level

A number between 1 and 9. 9 compresses best, but it also takes the longest.

odf_version

The ODF version of the output file. Default is the actual/most recent version.

  • By default the data and metadata are exported (export_data = TRUE).

  • To export only metadata and no data, select export_data = FALSE

Value

ZIP file and unzipped directory containing the data as CSV file and the metadata as XML file (DDI Codebook 2.5.).

Examples

# get example data from the opendataformat package
df  <-  get(data("data_odf"))

# write R data frame with attributes to the file my_data.zip specified
# as Open Data Format.
write_odf(x = df, paste0(tempdir(), "/my_data.zip"))

# write R data frame with attributes to the file my_data.zip
# with selected language.
write_odf(x = df,  paste0(tempdir(), "/my_data.zip"), languages = "en")

# write R data frame with attributes to the file my_data.zip but only
# metadata, no data.
write_odf(x = df,  file = paste0(tempdir(), "/my_data.zip"), export_data = FALSE)



opendataformat documentation built on April 3, 2025, 11:22 p.m.