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

1
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

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
data(Paivio)
# 2 lists, no selection on any variables
pickList(Paivio, nlists=2)

# define ranges for low and high on imagery, concreteness, meaningfulness
(low <- as.data.frame(apply(Paivio[,3:5], 2, fivenum))[c(1,3),])
(high <- as.data.frame(apply(Paivio[,3:5], 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)