I'm using the crab
data set from MASS
library in R Studio. I want to create a scatterplot matrix of the five quantitative variables and an interaction variable of sp.sex
as the only categorical variable using ggpairs
. I have reordered the factor levels as B.M, B.F, O.M, and O.F.
I would like to use a diverging 4-class RdYlBu color scheme from RColorBrewer
, where blue represents blue species and red represents orange species. Additionally, I would like to have two darker colors from the palette for male crabs and two lighter colors for females.
I have this code so far, but continue to get an error and no matrix output:
crabs$sp.sex <- factor(paste(crabs$sp, crabs$sex, sep="."), levels=c("B.M", "B.F", "O.M", "O.F"))
ggpairs(crabs, columns = 4:9, aes(color = sp.sex),
mapping = aes_string(fill = "sp.sex"),
lower = list(continuous = wrap("density", alpha = 0.5)),
diag = list(continuous = wrap("density", alpha = 0.5)),
upper = list(continuous = wrap("cor", size = 2)),
title = "Scatterplot Matrix of Crab Data") +
scale_color_manual(values = c("blue", "blue4", "orange4", "orange"),
labels = c("B.M", "B.F", "O.M", "O.F")) +
scale_fill_manual(values = brewer.pal(4, "RdYlBu"),
labels = c("B.M", "B.F", "O.M", "O.F")) +
theme_bw()
The error I get is this:
Error in stop_if_params_exist(params) :
'params' is a deprecated argument. Please 'wrap' the function to supply arguments. help("wrap", package = "GGally")
There is no output coming up in the plot window.