Description Usage Arguments Value Examples
View source: R/crossplot_print_stats.R
A convience function to print the plot stats and a regression line
1 2 3 4 |
p |
a crossplot |
text.pos |
the text position to be passed to
|
stats |
character vector with the stats that will be printed
(in order). Possible statistics include |
reg.color |
a string with the |
reg.linetype |
a string with the |
log.reg |
logical. If set to |
weighted |
logical. If set to |
sprintf.format |
character string with the |
xlabel |
the label for the x-axis variable |
ylabel |
the label for the y-axis variable |
reg.label.se |
logical. If set to |
mean.label.se |
logical If set to |
... |
Other arguments to be passed to
|
a ggplot2
plot with the regression line and label
added
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | data(mtcars)
p <- crossplot(mtcars, x.var = "hp", y.var = "mpg", size.var = "wt",
shapes.var = "cyl")
##Print weighted regression line and weighted stats
crossplot_print_stats(p, text.pos = c(200, 25), weighted = TRUE)
##Print unweighted regression line and unweighted stats
crossplot_print_stats(p, text.pos = c(200, 25), weighted = FALSE)
##passing other arguments to cowplot::draw_label.
##See ?cowplot::draw_label for more details
crossplot_print_stats(p, text.pos = c(200, 25), weighted = FALSE,
fontface = "bold")
## -- Controlling for qsec weighted by wt -- ##
##First see the results using a normal regression
mod <- lm(mpg ~ hp + qsec, mtcars, weights = wt)
library(sandwich); library(lmtest)
coeftest(mod, vcov = sandwich)
##Now in a plot
p2 <- crossplot(mtcars, x.var = "hp", y.var = "mpg", size.var = "wt",
shapes.var = "cyl", control.vars = "qsec")
crossplot_print_stats(p2, text.pos = c(0, 7), weighted = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.