I have been working with R for a few months now and am finally ready to start publishing some of my work. The only issue is that much of my analysis centers around presenting visualizations I generated with ggplot2 and mapview.
Using Rstudio, I choose the "knit to html" button, but notice that none of my visualizations actually appear in the html document.
I have a feeling this has to do with my YAML header, but I am having a difficult time finding a straight answer on what I need to add in order to automatically generate my plots.
My header is as follows:
title: "###"
author: "###"
date: "###"
output:
html_document:
toc: yes
toc_depth: 2
toc_float: yes
pdf_document:
toc: yes
toc_depth: '2'
knitr::opts_chunk$set(echo = TRUE)
Here's an example of the code chunk in markdown where I would like the visualization to appear directly below the code:
viz_trips_by_weekday <- ggplot(data = trips_by_weekday)+
geom_col(mapping = aes(x = weekday,
y = ride_count,
fill = customer_type),
position = 'dodge')+
labs(title = "Annual Ride Count By Weekday",
x = "Day of Week",
y = "Number of Rides",
)
print(viz_trips_by_weekday)
Any help would be greatly appreciated!