Binds experiment data together with analysis results and optionally writes this to file.

export_results(experiment, strategies = NULL, tracks = "all", file = NULL)

Arguments

experiment

An rtrack_experiment object from read_experiment.

strategies

An optional rtrack_strategies object generated by call_strategy. If present, the strategies corresponding to the tracks in the experiment (after subsetting using the tracks parameter) will be extracted and returned in the results.

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 results will be written. If NULL (the default), the data will be returned as a data.frame.

Value

A data.frame containing the experimental groups and factors (as supplied in the original experiment description) together with the summary metrics. This is returned invisibly if file is specified.

Details

If only the results matching a thresholded subset of strategies should be exported, then this can be achieved by performing strategy calling and thresholding separately and passing the strategies$tracks component of the resulting rtrack_strategies object to this function as the parameter tracks. This will restrict the output of export_results to only the tracks where an above-threshold strategy has been determined.

If the parameter file is supplied, the file extension will be used to determine which format to save the file in. The formats ".csv", ".csv2" (see write.table for details of the formats), ".tsv" ( tab-delimited text; can also be written as ".txt" or ".tab") and ".xlsx" are supported. If the file extension is not in this list, the data will be written as tab-delimited text with a warning. Note that the Excel ".xlsx" format is supported, but the older ".xls" is not.

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  
# The code below returns a data.frame.
# Use the parameter 'file' to write to a file instead.
export_results(experiment)
#>         Track_ID _TargetID _Day _Trial _Arena Strain Probe path.length
#> Track_1  Track_1      B6_9    1      1  Arena     B6 FALSE    335.0677
#>         total.time velocity distance.from.goal distance.from.old.goal
#> Track_1      15.76 22.28225           53.91705                     NA
#>         initial.heading.error initial.trajectory.error initial.reversal.error
#> Track_1              78.63183                 105.8627                     NA
#>         efficiency roaming.entropy latency.to.goal latency.to.old.goal
#> Track_1   1.639344       0.7502153           14.64                  NA
#>         time.in.wall.zone time.in.far.wall.zone time.in.annulus.zone
#> Track_1          3.263434              4.855354             3.263434
#>         time.in.goal.zone time.in.old.goal.zone time.in.n.quadrant
#> Track_1          1.193939                    NA           6.128889
#>         time.in.e.quadrant time.in.s.quadrant time.in.w.quadrant goal.crossings
#> Track_1           1.114343            3.74101           4.775758              1
#>         old.goal.crossings
#> Track_1                 NA