scatter | R Documentation |
This function will plot two variables (based on their common names), calculate their Coefficient of Correlation (CC), plot a linear regression line and color the background if the correlation is positive (red), negative (blue) or non-significant (white)
scatter(
x,
y,
method = "pearson",
threshold = 0.01,
showLine = TRUE,
grid = TRUE,
bgcol = FALSE,
pch = 20,
subtitle = NULL,
extendXlim = FALSE,
ci = FALSE,
...
)
x |
The first named vector |
y |
The second named vector |
method |
a character string indicating which correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman": can be abbreviated. |
threshold |
a numeric value indicating the significance threshold (p-value) of the correlation, in order to show a colored background. Default is 0.01. |
showLine |
a boolean indicating if a linear regression line should be plotted. Default is TRUE |
grid |
a boolean indicating whether to show a plot grid. Default is TRUE |
bgcol |
Boolean. Should a background coloring associated to significance and sign of correlation be used? Default is TRUE, and it will color the background in red if the correlation coefficient is positive, in blue if negative, in white if not significant (accordin to the _threshold_ parameter) |
pch |
the _pch_ parameter indicating the points shape. Default is 20 |
subtitle |
NULL by default, in which case the function will print as a subtitle the correlation coefficient (CC) and its pvalue. Otherwise, a user-provided string, bypassing the predefined subtitle |
extendXlim |
logical. If TRUE, the x-axis limits are extended by a fraction (useful for labeling points on the margins of the plot area). Default is FALSE |
ci |
logical. If TRUE, confidence intervals of linear regression are shown at 95 percent confidence. |
... |
Arguments to be passed to the core _plot_ function (if a new plot is created) |
A plot
x<-setNames(rnorm(200),paste0("var",1:200))
y<-setNames(rnorm(210),paste0("var",11:220))
scatter(x,y,xlab="Variable x",ylab="Variable y",main="Scatter plot by corto package",ci=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.