prepr: Preprocessing data from 2D mousetracking data in dual choice...

Description Usage Arguments Value Author(s) References Examples

View source: R/prepr.R

Description

Function normalizes trajectories with respect to time or space.

Usage

1
prepr(data, i.xyt, i.id, type, steps = 101, start2zero = TRUE, stretch = NA, takeAllvar = FALSE)

Arguments

data

A data frame containing the x, y, t variables and indicator variables which uniquely identify single trajectories

i.xyt

Vector containing the column names of the x, y, t variables in that order.

i.id

Vector containing the column names of the indicator variables that jointly uniquely identify single trajectories (e.g. c('participant_id', 'trial_id')).

type

type='time' normalizes trajectory with respect to time (all trajectories have the same number of steps of time steps). This is the standard data preprocessing procedure for mousetracking. type='spatial' normalizes trajectories with respect to space, i.e. we place a specified number of equally spaced (with respect to space) points on the trajectory. This is useful for comparing trajectories using a distance measure.

steps

The number of steps that should intrapolated (with respect to time or space, depending on type )

start2zero

If TRUE, the startpoint of each trajectory is set to (0,0)

stretch

Each trajectory is 'streched' into a specified norm-display. The norm display is specified as a list with the coordinates of the start point and the two possible end points of the trajectories. See the example below. This is useful for comparing data from various studies with different layout.

takeAllvar

Default FALSE. If TRUE, the returned dataframe contains all columns of the input dataframe. Otherwise only the columns x,y,t and the id-variables are returned.

Value

The function returns a list:

call

Returns all function input except the data.

data

Returns a data frame with normalized trajectories.

Author(s)

Jonas Haslbeck <jonashaslbeck@gmail.com>

References

Spivey, M. J., Grosjean, M., & Knoblich, G. (2005). Continuous attraction toward phonological competitors. Proceedings of the National Academy of Sciences of the United States of America, 102(29), 10393-10398.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 

# THIS EXAMPLE DOES NOT WORK ANYMORE !!!


# we use a part of the following example dataset

head(data_sp2015)

# we use prepr() to time normalize all trajectories to 101 time-steps and strech them to a norm display

layout_stretch <- list("start"=c(0,0), "left"=c(-1,1.5), "right"=c(1,1.5))

output <- prepr(data = data_sp2015[1:1000,], 
                i.xyt = c('x', 'y', 't'), 
                i.id =  c('id.ptp', 'id.trial'), 
                type = "time", 
                steps = 101, 
                start2zero = TRUE, 
                stretch = layout_stretch)

head(output$data)


## End(Not run)

jmbh/mta documentation built on May 19, 2019, 1:51 p.m.

Related to prepr in jmbh/mta...