Correlation measures the strength of linear association between two numeric variables. It ranges in value from -1 to 1. Drag the slider to visualize different correlations between x and y. Click New Sample to generate new data at a specified correlation strength.
The correlation coefficient is calculated by:
$$r_{xy} = \frac{\text{Cov}(x,y)}{\text{SD}_x\text{SD}_y}$$
where $\text{Cov}$ is covariance and $\text{SD}$ is standard deviation. This is known as Pearson's correlation.
This can be calculated in R as cov(x, y)/(sd(x) * sd(y))
or simply cor(x, y)
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.