Description Usage Arguments Details Value Note See Also Examples
Random generation from multiple normal distributions with potentially different means and standard deviations.
1 2 3 4 5 6 7 8 9 |
n |
vector of number of observations. |
mean |
vector of means. |
sd |
vector of standard deviations. |
exact |
a logical that indicates whether the resulting vector of random numbers will have the exact mean and standard deviation supplied in |
grp.labels |
Labels for the levels representing the different groups. |
var.labels |
Labels for or names for the columns of the resulting data.frame. |
digits |
A number of digits to which the numeric data should be rounded. |
All of n
, mean
, sd
, and grp.labels
must be of the same length.
If digits
is non-null and exact=TRUE
the resulting quantitative data will only be approximately exact (due to the rounding).
A data.frame with two columns is returned. The first columns is the random normal deviates and the second column are the group levels.
This function can be used to generate “realistic” data when one knows the sample size, mean, and standard deviation for several groups and it can be assumed that the data in each group follows a normal distribution. Thus, this function can be used to generate “actual” data for, for example, one-way and two-way ANOVA from summaries of group sample sizes, means, and standard deviations. Note that standard deviations can often be estimated by “back-calculating” from given standard errors or confidence intervals.
1 2 3 4 5 6 7 8 9 10 | # using default names
rand.data <- mrnorm(n=c(10,15,20),mean=c(10,15,15),sd=c(3,4,5))
# using custom names
rand.data1 <- mrnorm(n=c(10,15),mean=c(10,15),sd=c(3,4),
grp.labels=c("First","Second"),var.labels=c("Y","X"))
if (require(FSA)) {
Summarize(measure~group,data=rand.data)
Summarize(Y~X,data=rand.data1)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.