pickList: Select Items from a Word Pool in Given Ranges

View source: R/pickList.R

pickListR Documentation

Select Items from a Word Pool in Given Ranges

Description

This is a convenience function to provide the capability to select items from a given word pool, with restrictions on the range of any numeric variables.

Usage

pickList(data, ranges, nitems = 10, nlists = 1, replace = FALSE)

Arguments

data

A data.frame, typically a word list like Paivio or TWP

ranges

A data.frame of two rows, and with column names corresponding to a subset of the column names in data. The two rows give the minimum and maximum values, respectively, of variables in data. Alternatively, you can supply a named list containing the minimum and maximum values for one or more variables in data.

nitems

Number of items per list

nlists

Number of lists

replace

A logical value, indicating whether the sampling of items (rows) of data is to allow sampling with replacement.

Details

sample will generate an error if fewer than nitems * nlists items are within the specified ranges and replace=FALSE.

Value

A data frame of the same shape as data containing the selected items prefixed by the list number.

Author(s)

Michael Friendly

References

A related word list generator: Friendly, M. Word list generator. http://datavis.ca/online/paivio/

See Also

sample

Examples

data(Paivio)
# 2 lists, no selection on any variables
pickList(Paivio, nlists=2)

# Define ranges for low and high on imagery, concreteness, meaningfulness
# These go from low - median, and median-high on each variable
vars <- 3:5
(low <- as.data.frame(apply(Paivio[,vars], 2, fivenum))[c(1,3),])
(high <- as.data.frame(apply(Paivio[,vars], 2, fivenum))[c(3,5),])

# select two lists of 10 low/high imagery items
lowI <- pickList(Paivio, low[,"imagery", drop=FALSE], nitems=10, nl=2)
highI <- pickList(Paivio, high[,"imagery", drop=FALSE], nitems=10, nl=2)

# compare means
colMeans(lowI[,c(4:8)])
colMeans(highI[,c(4:8)])

# using a list of ranges
L <- list(imagery=c(1,5), concreteness=c(1,4))
pickList(Paivio, L)

WordPools documentation built on Aug. 8, 2023, 5:11 p.m.