This is how I am using knitr to display a plot. I get the message "df_max cannot be found" so it seems that df_max is not globally used by the knitr code. Could you help with this?
# Initialize device
dev.new(width =20000, height = 10000, unit = "px")
# Plot the event types that cause the largest number of injuries across all the states in the USA. Include the summary statistics table on the graph
p1 <- ggplot(df_max, aes(EVTYPE, INJURIES)) + geom_point(color = "blue") + theme(legend.position="top") +
theme(axis.text.x = element_text(color = "grey20", size = 7.0, angle = 90, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 5, angle = 50, hjust = 0.5, vjust = 0, face = "plain")) +
ggtitle("Health Inpact - INJURIES - of Severe Storms Across the USA") +
theme(plot.title = element_text(size = 10, face = "bold")) +
xlab("STORM EVENT TYPE") +
theme(axis.title.y = element_text(size = rel(0.5), angle = 90), axis.title=element_text(size=14,face="bold")) +
theme(axis.title.x = element_text(size = rel(0.5), angle = 0), axis.title=element_text(size=14,face="bold")) +
annotation_custom(tableGrob(round(stats, digits = 3), theme=ttheme_minimal(base_size = 7)))
# Plot the events causing the maximum amount of property damage across cost1a states. Include the summary statistics table on the graph.
p2 <- ggplot(cost1a_max, aes(EVTYPE, PROPDMG)) + geom_point(color = "blue") + theme(legend.position="top") +
theme(axis.text.x = element_text(color = "grey20", size = 7.0, angle = 90, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 5, angle = 50, hjust = 0.5, vjust = 0, face = "plain")) +
ggtitle("Economic Inpact - PROPERTY DAMAGE - of Severe Storms across the states of GU, TX, AK, TN, CA, KY, VI, IL, WI,MS, UT, CO, ND") +
theme(plot.title = element_text(size = 10, face = "bold"), axis.title=element_text(size=14,face="bold")) +
xlab("STORM EVENT TYPE") +
theme(axis.title.y = element_text(size = rel(0.5), angle = 90), axis.title=element_text(size = 14, face = "bold")) +
theme(axis.title.x = element_text(size = rel(0.5), angle = 0), axis.title=element_text(size=14,face="bold")) +
annotation_custom(tableGrob(round(statsa, digits = 3), theme=ttheme_minimal(base_size = 7)))
Plot 2 graphs on the same panel
grid.arrange(p1, p2)