R/plot.activity_presence.R

Defines functions plot_activity_presence

plot_activity_presence <- function(x, ...) {

	mapping <- attr(x, "mapping")
	relative <- NULL

	x %>%
		ggplot(aes_string(glue::glue("reorder({mapping$activity_id}, relative)"), "relative")) +
		geom_col(aes(fill = relative)) +
		scale_fill_continuous_tableau(name = "Activity Presence", palette = "Blue")+
		theme_light() +
		coord_flip() +
		labs(x = "Activity", y = "Relative Activity Presence") -> p


	if(!is.null(mapping$groups)) {
		p <-	p + facet_grid(as.formula(paste(c(paste(mapping$groups, collapse = "+"), "~." ), collapse = "")), scales = "free_y")
	}

	return(p)
}

Try the edeaR package in your browser

Any scripts or data that you put into this service are public.

edeaR documentation built on April 27, 2023, 9:07 a.m.