jacob-long / jacob-long/interactions
Change point shape using a variable not involved in the interaction
- Dominant language
- R
- Stars
- 135
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
I am currently using your fabulous interactions package to visualise some statistical models I am running. I especially appreciate the interoperability with ggplot2. However, one thing I cannot work out how to do is change point shape by a variable that is not involved in the interaction. Specifically, I have a categorical variable with three levels in my model (as a random factor), and I would like the points to be shaped according to the levels of that factor. I'm sure this is quite a basic question, but I cannot work out how to use the point.shape argument to map to a factor not involved in the interaction, or to otherwise add a shape aesthetic to the graph. Any advice you can give would be hugely appreciated.
EXAMPLE:
My graph as it currently stands has the following code:
graph<- interact_plot(model1, pred="Mean_AlphaPhy",
modx = "Disturbance", plot.points=TRUE, partial.residuals = TRUE) +
scale_y_continuous(trans='log10') +
xlab("Mean Alpha Phylogenetic Diversity") + ylab("Number of plants colonising") +
scale_color_manual(values=c("#999999", "#E69F00")) +
scale_linetype_manual(values=c("solid", "solid")) +
theme_bw() + guides(linetype = "none") + theme(legend.position = "top") +
theme(axis.text=element_text(size=7),
axis.title=element_text(size=9),
legend.text=element_text(size=7),
legend.title=element_text(size=9))
And it is based on this model:
model1 <- glmmTMB(germ_num ~ Mean_AlphaPhy*Disturbance + propagule_pressure +
suitabilitypc1V2abs + suitabilitypc2V2abs + Density +
(1|Family) + (1|POWO.name) + (1|Site) + (1|Study),
family=nbinom2(link = "log"),
data=germinationcount)
I would like the graph to be exactly as it is, but with the points having one of three shapes, determined by the levels of 'Study'.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the interact_plot entry point and inspect how point.shape and plot.points are handled when the requested variable is not part of the interaction. Use the supplied model and Study factor as the reproduction case; done means the existing plot remains unchanged except that points use three shapes based on Study.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100