Closed ldecicco-USGS closed 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
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)
}
geom_line
to either geom_point
or geom_bar
:palm_tree:
:100:!
:v: :vertical_traffic_light:
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: