Description Usage Arguments Value Examples
View source: R/visualization-utils.R
This function is a wrapper around the typical ggplot
command to create two
dimensional scatterplots, i.e. using geom_point
. It provides the option of
colouring point by a third variable, one that is usually, though not
necessarily categorical. Also, it provides the option of placing the line of
best fit on the scatterplot. If points are coloured by a categorical
variable, the a different line of best for each value of the categorical
variable is provided.
1 2 3 4 5 6 7 8 9 |
x |
A numeric variable in |
y |
A numeric variable in |
data |
A data frame with the |
by |
An optional variable, usually categorical (factor or character), by which the points in the scatterplot are byed and coloured. |
best_fit_line |
A logical variable indicating if the line of best fit should shown or not. |
xlab |
The label of the x-axis (defaults to the |
ylab |
The label of the y-axis (defaults to the |
A ggplot2::ggplot
object, which may be modified with further ggplot2
commands.
1 2 3 4 5 6 7 | scatterplot(x = attractive, y = trustworthy, data = faithfulfaces)
scatterplot(x = attractive, y = trustworthy, data = faithfulfaces,
xlab = 'attractiveness', ylab = 'trustworthiness')
scatterplot(x = attractive, y = trustworthy, data = faithfulfaces,
by = face_sex)
scatterplot(x = trustworthy, y = faithful, data = faithfulfaces,
by = face_sex, best_fit_line = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.