name_regions: Assign meaningful names to regions in eye-tracking data

Description Usage Arguments Details Value

View source: R/helper_functions.R

Description

The function adds a column to the data.frame with region names. It can assign different region names to the same regions identifiers, if this differs for subsets of stimuli. E.g. if you have two type of stimuli, and for one of them critical region is the fourth one, and for the other - the fifth one, the function will be able to take this into account.

Usage

1
2
name_regions(dat, reg.names, region.col = region, reg.names.col = reg.name,
  type.col, missing.prefix = "Reg_")

Arguments

dat

data.frame to add region names to

reg.names

either a vector of region names or a list with vectors of regions names. See "Details" on the exact format and difference between the two scenarios

region.col

unquoted name of the column with original regions identifiers, which have to be assigned new names

reg.names.col

unquoted name of the coumn with region names which will be added to the data; "reg.name" by default

type.col

unquoted name of the column specifying stimuli types, if it is necessary to assign different names to the same region identifiers depending on the stimuli subset. See "Details".

missing.prefix

what to prefix to region identifiers for which the user didn't specify names explicitly. Defaults to "Reg_", i.e. if region identifiers are numbers, it would generate something like "Reg_1".

Details

The function has two scenarios of use. The first one: you only have one type of stimuli in the data, or, alternatively, you have several types of stimuli, but for each type the regions are identical. E.g. for all types of stimuli the fourth region is the critical one, and the fifth one is the spillover. In this case, reg.names argument should be a named vector, where names represent new names you want to assign to the regions, and values - region identifiers. E.g. reg.names <- c(critical = 4, spillover = 5). type.col should be left out.

The second scenario: you have several types of stimuli, and regions identifiers are not shared between types. E.g. for Type 1 critical region is the fourth one, and for Type 2 critical region is the third one. In this case, reg.names should be a list, where the name of each list component corresponds to one of the stimuli types, and the list components themselves are named vector like in the first scenario. E.g:

reg.names <- list(Type1 = c(critical = 4, spillover = 5), Type2 = c(critical = 3, spillover = 4))

In this case, the type.col should be the unquoted name of the column containing the names of stimuli types; these names should be the same as in the list above.

In either case, you can specify only some region names. In that case, the regions for which you didn't specify a name, will be given a name like "Reg_REGION.IDENTIFIER", e.g. "Reg_a" or "Reg_1".

Value

data.frame with the added reg.name column


antonmalko/ettools documentation built on May 28, 2019, 3:35 p.m.