FormatCorrelation | R Documentation |
Returns a function that takes x and y and returns a formatted output to describe the correlation of x and y
FormatCorrelation(
method = "pearson",
n.format = NULL,
coeff.format = "%.2f",
p.format = "%.2g",
slope.format = NULL,
rmsd.format = NULL,
min.obs = 5
)
method |
how to compute correlation coefficients (can be pearson, spearman or kendall) |
n.format |
format string for the number of data points (see sprintf); can be NULL (don't output the number of data points) |
coeff.format |
format string for the correlation coefficient (see sprintf); can be NULL (don't output the correlation coefficient) |
p.format |
format string for the P value (see sprintf); can be NULL (don't output the P value) |
slope.format |
format string for the slope (see sprintf); can be NULL (don't output the slope) |
rmsd.format |
format string for the root mean square deviation (see sprintf); can be NULL (don't output the rmsd) |
min.obs |
minimum number of observations (no output outerwise) |
Use this for the correlation
parameter of PlotScatter
The slope is computed via a principal component analysis and *not* by linear regression
a function
set.seed(42)
data <- data.frame(u=runif(500)) # generate some correlated data
data$x <- rnorm(500,mean=data$u)
data$y <- rnorm(500,mean=data$u)
fun <- FormatCorrelation()
fun(data$x,data$y)
fun <- FormatCorrelation(method="spearman",p.format="%.4g")
fun(data$x,data$y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.