generate.data: Generate Data

Description Usage Arguments Value Examples

View source: R/generate.data.R

Description

Generates data of sample size n with the exact specified mean and standard deviation.

Usage

1

Arguments

n

integer; sample size.

mean

integer; mean of the data.

sd

integer; standard deviation of the data.

Value

Generates a random value vector of length n with the specified mean and standard deviation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#simple example
data1 <- generate.data(n=10,mean=5,sd=1)

#multiple independent groups
means = c(0.36,-0.19,-0.18)
sds = c(1.08,0.53,0.81)
n = c(28,28,28) #N = 84
y <- list(NA)
for (i in 1:3){y[[i]] <- generate.data(n[i],means[i],sds[i])}
y <- unlist(y)
group <- c(rep(0,n[1]),rep(1,n[2]),rep(2,n[3]))
p <- length(unique(group))
data=data.frame(y=y,g=group)
aggregate(data$y,by=list(data$g),mean)

Example output

Loading required package: quadprog
Loading required package: shiny
  Group.1     x
1       0  0.36
2       1 -0.19
3       2 -0.18

ANOVAreplication documentation built on Sept. 27, 2021, 9:06 a.m.