Plots the global temperature anomaly retrieved using get_temp() with ggplot2. The output ggplot2 object may be further modified.

plot_temp(dataset = get_temp(), print = TRUE)

Arguments

dataset

Name of the tibble generated by get_temp

print

(boolean) Display temperature anomaly ggplot2 chart, defaults to TRUE. Use FALSE to not display chart.

Value

Invisibly returns a ggplot2 object with temperature anomaly chart

Details

plot_temp invisibly returns a ggplot2 object with a pre-defined temperature anomaly chart using data from get_temp. By default the chart is also displayed. Smooths using ggplot2's built-in loess smoother. Users may further modify the output ggplot2 chart.

Author

Hernando Cortina, hch@alum.mit.edu

Examples

# \donttest{ # Fetch temperature anomaly: anomaly <- get_temp()
#> Warning: InternetOpenUrl failed: 'The server name or address could not be resolved'
#> Error in download.file(file_url, dl): cannot open URL 'https://data.giss.nasa.gov/gistemp/tabledata_v4/GLB.Ts+dSST.csv'
# # Plot output using package's built-in ggplot2 defaults plot_temp(anomaly)
#> Error in ggplot(dataset, aes(x = Year, y = `J-D`)): object 'anomaly' not found
# Or just call plot_temp(), which defaults to get_temp() dataset plot_temp()
#> Warning: InternetOpenUrl failed: 'The server name or address could not be resolved'
#> Error in download.file(file_url, dl): cannot open URL 'https://data.giss.nasa.gov/gistemp/tabledata_v4/GLB.Ts+dSST.csv'
p <- plot_temp(anomaly, print = FALSE)
#> Error in ggplot(dataset, aes(x = Year, y = `J-D`)): object 'anomaly' not found
p + ggplot2::labs(title='The Signature of Climate Change') # }
#> Error in eval(expr, envir, enclos): object 'p' not found