Description Usage Arguments Value See Also Examples
View source: R/ggplot_parallel_slopes.R
NOTE: This function is deprecated; please use geom_parallel_slopes()
instead. Output a visualization of linear regression when you have one numerical
and one categorical explanatory/predictor variable: a separate colored
regression line for each level of the categorical variable
1  gg_parallel_slopes(y, num_x, cat_x, data, alpha = 1)

y 
Character string of outcome variable in 
num_x 
Character string of numerical explanatory/predictor variable in

cat_x 
Character string of categorical explanatory/predictor variable
in 
data 
an optional data frame, list or environment (or object
coercible by 
alpha 
Transparency of points 
A ggplot2::ggplot()
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32  ## Not run:
library(ggplot2)
library(dplyr)
library(moderndive)
# log10() transformations
house_prices < house_prices %>%
mutate(
log10_price = log10(price),
log10_size = log10(sqft_living)
)
# Output parallel slopes model plot:
gg_parallel_slopes(
y = "log10_price", num_x = "log10_size", cat_x = "condition",
data = house_prices, alpha = 0.1
) +
labs(
x = "log10 square feet living space", y = "log10 price in USD",
title = "House prices in Seattle: Parallel slopes model"
)
# Compare with interaction model plot:
ggplot(house_prices, aes(x = log10_size, y = log10_price, col = condition)) +
geom_point(alpha = 0.1) +
geom_smooth(method = "lm", se = FALSE, size = 1) +
labs(
x = "log10 square feet living space", y = "log10 price in USD",
title = "House prices in Seattle: Interaction model"
)
## End(Not run)

sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Plotting parallel slopes models is now much easier using the
`geom_parallel_slopes()` function. We suggest you use
`geom_parallel_slopes()` instead of `gg_parallel_slopes()`; read the help
file by running `?geom_parallel_slopes` to learn how.
Warning message:
'gg_parallel_slopes' is deprecated.
Use 'geom_parallel_slopes()' instead.
See help("Deprecated")
`geom_smooth()` using formula 'y ~ x'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.