Learn R Programming

Rtrack (version 1.0.7)

export_json: Export experiment data to a JSON file.

Description

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

Usage

export_json(experiment, tracks = "all", file = NULL)

Value

This function invisibly returns the JSON data as a character string.

Arguments

experiment

An rtrack_experiment object from read_experiment.

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.

file

The file to which the JSON data will be written. If NULL (the default), nothing will be written.

Details

The exported JSON file contains all the raw data and experiment metadata. The JSON 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 JSON format can be found in the schema file at https://rupertoverall.net/Rtrack/Rtrack_schema_v1.json.

See Also

read_experiment to import the JSON file back into R.

Examples

Run this code
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"))
tempfile <- file.path(tempdir(), "Minimal_experiment.json") # Temporary file
export_json(experiment, file = tempfile)
imported.experiment <- read_experiment(tempfile, format = "json")
# Experiments are identical except for export timestamp/notes
all.equal(experiment, imported.experiment)
identical(experiment$metrics, imported.experiment$metrics)

Run the code above in your browser using DataLab