USGS-R / wateRuse

Moved to: https://code.usgs.gov/water/water-use/wateruse
https://code.usgs.gov/water/water-use/wateruse
Creative Commons Zero v1.0 Universal
7 stars 11 forks source link

Plot time-series data for data elements #8

Closed ldecicco-USGS closed 8 years ago

ldecicco-USGS commented 8 years ago

Create graphs of time (year) vs. a data element selected.

Have the option to create for all counties for a state, or select certain counties. Or select counties or HUCS from several states.

Have the option to plot the y-axis with different ranges:

ldecicco-USGS commented 8 years ago
timeDF <- data.frame(
  year = c(1985, 1990, 1995, 2000),
  A = c(1,2,3,4),
  B = c(2,2,2,3),
  C = c(4,3,3,2)
)

library(ggplot2)

timePlot <- ggplot(data = timeDF) +
  geom_line(aes(x = year, y = A)) + 
  geom_line(aes(x = year, y = B))

timePlot

library(tidyr)

longTime <- gather(timeDF, county, population, -year)

longPlot <- ggplot(data = longTime) +
  geom_line(aes(x = year, y = population, color = county))
longPlot
jshourds-usgs commented 8 years ago

This is what Gary, Laura, and Jen came up with for plotting time series data.

#' time_series_data
#'
#' time_series_data
#' 
#' @param data.elements character name of data element within available categories by year for state
#' @param years vector of integers specifying all years available for state. Defaults to NA which shows all years in dataset.
#' @param w.use is the datafile that includes all areas in all data elements for state
#' @param areas is a geographical area as defined in your datafile such as county, HUC, or aquifer
#' @param y.scale allows R to set the y-axis scale given available data range. Defaults to NA which lets R set the scale based on dataset values.
#' @param log = TRUE or FALSE allows user to set log scale, default is FALSE
#'
#' 
#' @export
#' 
#' @examples 
#' 
#' year1 <- 2005
#' year2 <- 2010
#' years <- c(year1, year2)
#' areas <- c("Dane","Milwaukee")
#' data.element <- "PS-GWPop"
#' w.use <- NA
#' time_series_data(w.use, data.element)
time_series_data <- function(w.use, data.elements, years= NA, areas= NA, y.scale=NA, log= FALSE){

  return(NA)
}
ldecicco-USGS commented 8 years ago
jshourds-usgs commented 8 years ago

:palm_tree:

dblodgett-usgs commented 8 years ago

:100:!

jshourds-usgs commented 8 years ago

:v: :vertical_traffic_light: