Skip to content

Instantly share code, notes, and snippets.

View thomas-neitmann's full-sized avatar

Thomas Neitmann thomas-neitmann

View GitHub Profile
install.packages("ggtext")
install.packages("mdthemes")
plot + mdthemes::as_md_theme(theme_minimal())
plot +
labs(
x = "**Year**",
y = "Revenue (*Billion* USD)",
caption = "Data Source: *en.wikipedia.org/wiki/List_of_largest_biomedical_companies_by_revenue*"
) +
mdthemes::md_theme_minimal()
plot + mdthemes::md_theme_minimal()
plot + theme_minimal()
<span style = 'color:color name or hex code'>Text you want to color</span>
library(ggplot2)
library(dplyr)
data(biomedicalrevenue, package = "ggcharts")
plot <- biomedicalrevenue %>%
filter(company %in% c("Roche", "Novartis")) %>%
ggplot(aes(year, revenue, color = company)) +
geom_line(size = 1.2) +
ggtitle(
paste0(
do_if <- function(data, predicate, expr) {
if (predicate) {
eval.parent(insert_data(
substitute(expr),
substitute(data)
))
} else {
data
}
}
`:=` <- function(lhs, rhs) {
var <- deparse(substitute(lhs))
if (exists(var, parent.frame(), inherits = FALSE)) {
stop("Variable `", var, "` is already defined.", call. = FALSE)
} else {
assign(var, rhs, parent.frame())
}
}
# An alternative version making use of `lockBinding`. This prevents users from overwriting