GRF: Generating random frequencies

View source: R/ANOFA-random.R

GRFR Documentation

Generating random frequencies

Description

The function GRF() generates random frequencies based on a design, i.e., a list giving the factors and the categories with each factor. The data are given in the compiled format.

Usage

GRF( design, n, prob = NULL, f = "Freq" )

Arguments

design

A list with the factors and the categories within each.

n

How many simulated participants are to be classified.

prob

(optional) the probability of falling in each cell of the design.

f

(optional) the column names that will contain the frequencies.

Details

The name of the function GRF() is derived from grd(), a general-purpose tool to generate random data \insertCitech19ANOFA now bundled in the superb package \insertCitecgh21ANOFA.

Value

a data frame containing frequencies per cells of the design.

References

\insertAllCited

Examples


# The first example disperse 20 particants in one factor having
# two categories (low and high):
design <- list( A=c("low","high"))
GRF( design, 20 )

# This example has two factors, with factor A having levels a, b, c:
design <- list( A=letters[1:3], B = c("low","high"))
GRF( design, 40 )

# This last one has three factors, for a total of 3 x 2 x 2 = 12 cells
design <- list( A=letters[1:3], B = c("low","high"), C = c("cat","dog"))
GRF( design, 100 )

# To specify unequal probabilities, use
design <- list( A=letters[1:3], B = c("low","high"))
GRF( design, 100, c(.05, .05, .35, .35, .10, .10 ) )

# The name of the column containing the frequencies can be changes
GRF( design, 100, f="patate")


ANOFA documentation built on Nov. 18, 2023, 5:06 p.m.