View source: R/plot_inventory_data.R
| plot_inventory_data | R Documentation | 
Returns a bar chart using ggplot2 that displays the
frequency of missing data for each element and station given.
Takes a data frame as an input and the relevant columns to create the plot.
plot_inventory_data(
  data,
  elements,
  station = NULL,
  y = c("count", "percentage"),
  columns = c("elements", "stations"),
  fill = c("none", "stations", "elements"),
  facet_by = c("stations", "elements", "none"),
  display_perc = FALSE,
  display_count = FALSE,
  title = "Inventory Plot",
  x_title = NULL,
  y_title = NULL,
  coord_flip = FALSE
)
| data | The data.frame to calculate from | 
| elements | The name of the columns in  | 
| station | The name of the station column in  | 
| y | Whether to display counts or percentages. | 
| columns | Whether to display stations or elements on the columns. | 
| fill | Whether to fill by stations, elements, or neither. | 
| facet_by | Whether to facet by stations, elements, or neither | 
| display_perc | logical. Whether to display percentage values on the plot. | 
| display_count | logical. Whether to display the count values on the plot. | 
| title | The text for the title. | 
| x_title | The text for the x-axis. | 
| y_title | The text for the y-axis. | 
| coord_flip | logical. Whether to switch the x and y axes. | 
A plot of type ggplot to the default plot device
data(daily_niger) 
plot_inventory_data(data = daily_niger, station = "station_name",
                    elements = c("tmin", "tmax"),
                    columns = "stations", facet_by = "elements")
                    
# can omit station argument
plot_inventory_data(data = daily_niger, 
                    elements = c("tmin", "tmax"))
# can view percentage instead
plot_inventory_data(data = daily_niger, y = "percentage",
                    elements = c("tmin", "tmax"), display_perc = TRUE,
                    display_count = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.