Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Last active May 2, 2024 05:10
Show Gist options
  • Save abikoushi/2739eb34ea8ebaee4dde772694c09bfa to your computer and use it in GitHub Desktop.
Save abikoushi/2739eb34ea8ebaee4dde772694c09bfa to your computer and use it in GitHub Desktop.
dot diagram (visualization of `formula`)
library(reshape2)
library(ggplot2)
theme_dotdiagram <- function(...){
theme_minimal(...)%+%
theme(axis.text.y = element_text(colour="black"),
axis.ticks = element_blank(),
axis.text.x = element_blank(),
axis.title.x = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major.x = element_blank())
}
f <- ~ Site+Sex+Age+Site:Sex+Age:Site+Age:Sex:Site
df <- melt(attr(terms(f),"factors")>0)
df <- df[df$value,]
ggplot(df,aes(x=Var2,y=Var1,group=Var2))+
geom_point(size=3)+
geom_path(linewidth = 1)+
theme_dotdiagram()+
ggtitle(label = paste(as.character(f),collapse = " "))
# ggsave("dot.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment