Creates a representation of the experiment data in the trackxf format and writes this to file.

export_data(experiment, file, tracks = "all")

Arguments

experiment

An rtrack_experiment object from read_experiment.

file

The file to which the archive will be written. This should ideally use the file extension .trackxf although other extensions are also possible. If the filename is given without any extension (recommended), then the .trackxf extension will be added automatically.

tracks

Which tracks should be exported. Default, "all" exports the entire experiment object. A subset of tracks can be specified using either numeric indices or a vector of track IDs following usual R standards.

Details

The exported trackxf file contains all the raw data and experiment metadata. The trackxf archive contains exactly the same information as if reading from raw data. Calculated metrics are not exported, but can be recreated exactly.

A formal description of the trackxf JSON format can be found in the schema file at https://rupertoverall.net/trackxf/trackxf_schema_v0.json.

See also

read_experiment to import the archive back into an rtrack_experiment object.

Examples

require(Rtrack)
experiment.description <- system.file("extdata", "Minimal_experiment.xlsx",
  package = "Rtrack")
experiment <- read_experiment(experiment.description, format = "excel",
  project.dir = system.file("extdata", "", package = "Rtrack"))
#>     Processing tracks.
#> 
  |                                                  | 0 % ~calculating  
  |==================================================| 100% elapsed=00s  
tempfile <- file.path(tempdir(), "Minimal_experiment.trackxf") # Temporary file
export_data(experiment, file = tempfile)
#>     Creating trackxf archive.
#> 
  |                                                  | 0 % ~calculating  
  |=============                                     | 25% ~00s          
  |=========================                         | 50% ~00s          
  |======================================            | 75% ~00s          
  |==================================================| 100% elapsed=00s  
#>     Compressing trackxf archive.
imported.experiment <- read_experiment(tempfile, format = "trackxf")
#>     Restoring archived experiment.
#>     Processing tracks.
#> 
  |                                                  | 0 % ~calculating  
  |==================================================| 100% elapsed=00s  
# Experiments are identical except for export timestamp/notes
all.equal(experiment, imported.experiment)
#> [1] "Component “info”: Component “export.note”: Component “software”: 1 string mismatch"
#> [2] "Component “info”: Component “export.note”: Component “version”: 1 string mismatch" 
#> [3] "Component “info”: Component “export.note”: Component “date”: 1 string mismatch"    
#> [4] "Component “info”: Component “export.note”: Component “url”: 1 string mismatch"     
identical(experiment$metrics, imported.experiment$metrics)
#> [1] TRUE