## define parameters
n <- 16
dfMeans <- c(2.5, 3.0, 3.0, 3.5)
dfSds <- c(1.0, 1.0, 1.5, 0.75)
lowerbound <- rep(1, 4)
upperbound <- rep(5, 4)
corMat <- matrix(
c(
1.00, 0.30, 0.40, 0.60,
0.30, 1.00, 0.50, 0.70,
0.40, 0.50, 1.00, 0.80,
0.60, 0.70, 0.80, 1.00
),
nrow = 4, ncol = 4
)
item_names <- c("Q1", "Q2", "Q3", "Q4")
rownames(corMat) <- item_names
colnames(corMat) <- item_names
## apply function
df <- makeItems(
n = n, means = dfMeans, sds = dfSds,
lowerbound = lowerbound, upperbound = upperbound, cormatrix = corMat
)
## test function
str(df)
# means
apply(df, 2, mean) |> round(3)
# standard deviations
apply(df, 2, sd) |> round(3)
# correlations
cor(df) |> round(3)
Run the code above in your browser using DataLab