ggfertilizer---
title: "Visualize fertilizer data in U.S. maps"
author: "Wenlong Liu"
date: "r Sys.Date()
"
output: rmarkdown::html_vignette
vignette: > %\VignetteIndexEntry{Visualize fertilizer data in U.S. maps} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8}
knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4 )
require(ggfertilizer) require(ggplot2) data("us_fertilizer_county") data = us_fertilizer_county
# Initilize input parameters. Year = 2001 Nutrient = "N" Farm_Type = "farm" Input_Type = "fertilizer" level = "county" # draw the map us_plot <- map_us_fertilizer(data = data, Year = Year, Nutrient = Nutrient, Farm_Type = Farm_Type, Input_Type = Input_Type, viridis_palette = "inferno", level = level) + ggtitle(paste(Nutrient, " from ", Input_Type, " input to ", Farm_Type, " in the year of ",Year, " at ", level, " level",sep = "")) us_plot
level = "state" Year = 1997 Input_Type = "manure" us_plot <- map_us_fertilizer(data = data, Year = Year, Nutrient = Nutrient, Farm_Type = Farm_Type, Input_Type = Input_Type, viridis_palette = "inferno", level = level) + ggtitle(paste(Nutrient, " from ", Input_Type, " input to ", Farm_Type, " in the year of ",Year, " at ", level, " level",sep = "")) us_plot
We can also change the projection system of the map to "albers" projection.
us_plot + ggtitle(paste(Nutrient, " from ", Input_Type, " input to ", Farm_Type, " in the year of ",Year, " at ", level, " level",sep = ""))+ coord_map("albers",lat0=39, lat1=45)
Year = c(1945, 1975, 2005) facet = "Year" nutrient = "N" Input_Type = "fertilizer" level = "county" us_plot <- map_us_fertilizer(data = data, Year = Year, Nutrient = Nutrient, Farm_Type = Farm_Type, Input_Type = Input_Type, viridis_palette = "inferno", level = level, facet = facet) + ggtitle(paste(Nutrient," input "," from ", Input_Type, " to ", Farm_Type, " at ", level, " level",sep = "")) us_plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.