Count number of observations per trial for a specified dimension (or several) in the trajectory array. This is mostly a helper function used by other functions in this package.

mt_count(data, use = "trajectories", save_as = "measures", dimensions = "xpos")

Arguments

data

a mousetrap data object created using one of the mt_import functions (see mt_example for details). Alternatively, a trajectory array can be provided directly (in this case use will be ignored).

use

a character string specifying which trajectory data should be used.

save_as

a character string specifying where the resulting trajectory data should be stored.

dimensions

a character vector specifying the name of the dimension(s) that should be used for counting the number of observations. If several dimensions are specified, the number of complete observations are reported.

Value

A mousetrap data object (see mt_example).

If a data.frame with label specified in save_as (by default "measures") already exists, the number of observations (called nobs) are added as additional column. If not, an additional data.frame

will be added.

If a trajectory array was provided directly as data, only a named character vector will be returned.

Author

Pascal J. Kieslich

Examples

# Retrieve vector that counts number of observations
mt_count(mt_example$trajectories)
#> id01 id02 id03 id04 id05 id06 id07 id08 id09 id10 id11 id12 id13 id14 id15 id16 
#>  173  280  153  174  334  311  234  203  250  201  283  355  242  465  219  230 
#> id17 id18 id19 id20 id21 id22 id23 id24 id25 id26 id27 id28 id29 id30 id31 id32 
#>  158  355  398  121  145  167  117  102   80   89   85  125  110   81  105   72 
#> id33 id34 id35 id36 id37 id38 
#>  210  110  457  157  100  133