simCorVars: Simulate correlated variables.

Description Usage Arguments Details Value Author(s) Examples

View source: R/simCorVars.R

Description

The function simulates a pair of correlated variables.

Usage

1
simCorVars(n, r, plot = TRUE)

Arguments

n

integer: sample size.

r

numeric: correlation.

plot

logical: generate scatter plot of the variables.

Details

The function is mainly for teaching purposes and simulates n observations from a pair of normal distributed variables with correlation r.

By specifying plot = TRUE a scatter plot of the data is generated.

Value

data.frame with entries Var1 and Var2

Author(s)

Matthias Kohl Matthias.Kohl@stamats.de

Examples

1
2
res <- simCorVars(n = 100, r = 0.8)
cor(res$Var1, res$Var2)

MKmisc documentation built on May 19, 2017, 11:22 a.m.

Search within the MKmisc package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.