constructs: Get or replace construct poles

View source: R/repgrid-constructs.r

constructsR Documentation

Get or replace construct poles

Description

Allows to get and set construct poles. Replaces the older functions getConstructNames, getConstructNames2, and eNames which are deprecated.

Usage

constructs(x, collapse = FALSE, sep = " - ")

constructs(x, i, j) <- value

leftpoles(x)

leftpoles(x, position) <- value

rightpoles(x)

rightpoles(x, position) <- value

Arguments

x

A repgrid object.

collapse

Return vector with both poles instead.

sep

Separator if collapse = TRUE, default is " - ".

i, j

Row and column Index of repgrid matrix.

value

Character vector of construct poles names.

position

Index where to insert construct

Examples


# shorten object name
x <- boeker

## get construct poles
constructs(x) # both left and right poles
leftpoles(x) # left poles only
rightpoles(x)
constructs(x, collapse = TRUE)

## replace construct poles
constructs(x)[1, 1] <- "left pole 1"
constructs(x)[1, "leftpole"] <- "left pole 1" # alternative
constructs(x)[1:3, 2] <- paste("right pole", 1:3)
constructs(x)[1:3, "rightpole"] <- paste("right pole", 1:3) # alternative
constructs(x)[4, 1:2] <- c("left pole 4", "right pole 4")

l <- leftpoles(x)
leftpoles(x) <- sample(l) # brind poles into random order
leftpoles(x)[1] <- "new left pole 1" # replace name of first left pole

# replace left poles of constructs 1 and 3
leftpoles(x)[c(1, 3)] <- c("new left pole 1", "new left pole 3")


markheckmann/OpenRepGrid documentation built on April 14, 2024, 8:15 a.m.