Open Mind, a climate trend data analysis blog, has a great Climate Data Service that provides updated consolidated csv file with 170 monthly climate time series. This is a great resource for those interested in studying climate change. Quick, reliable access to 170 up-to-date climate time series will save interested analysts hundreds – thousands of data wrangling hours of work.
This post presents a simple R script to show how a user can select one of the 170 data series and generate a time series plot like this:
Plot scaling and labeling is automatically generated by this R script.
## Open Mind Blog offers a Climate Data Service : https://tamino.wordpress.com/2016/04/10/climate-data-service-2/ ## Script to read OMDS - Produce simple trend chart ## User is prompted to enter series_id ## Script reads OMDS file01 and plot time series for requested series_id # Establish diretory path and file names my_dir <- "F:\\R_Home\\Charts & Graphs Blog\\RClimateTools\\_Next_generation\\OMDS" setwd(my_dir) file_id <- "CD01.csv" fields <- "Fields01.csv" # Get OMDS file 1 variable list my_vars <- read.csv(fields,as.is=T) # Read OMDS file01 full_df <- read.csv(file_id,as.is=T) # Prompt user to enter series_id series_id <- as.numeric(readline("What is the series_id that you would like o plot? ")) series_name <- my_vars[series_id,1] series_unit <- my_vars[series_id,2] series_note <- my_vars[series_id,3] # Subset data.frame to get date and requested variable anal_df <- full_df[,c(1, series_id)] anal_df <- subset(anal_df, anal_df != "NA") # Establish dates for 1st & last records in series min_dt <- anal_df[1,1] max_dt <- anal_df[nrow(anal_df),1] max_y_val <- max(anal_df[,2]) # Plot Data Series par(las=1) title<- paste(names(anal_df), " (series ", series_id, ") data plot\n", min_dt, " to ", max_dt, sep="") y_axis_lab <- paste(series_name, " - ", series_unit, sep="") plot(anal_df[,1], anal_df[,2], type="l", xlab="", ylab = y_axis_lab, main = title) text(min_dt + 10, max_y_val, series_note ,adj=0)