Access and Analyze 170 Monthly Climate Time Series Using Simple R Scripts

August 2, 2016

(This article was first published on RClimate, and kindly contributed to R-bloggers)

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 :
## 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"
   file_id <- "CD01.csv"
   fields <- "Fields01.csv"

# Get OMDS file 1 variable list
   my_vars <- read.csv(fields,

# Read OMDS file01
 full_df <- read.csv(file_id,

# 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[2] != "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
  title<- paste(names(anal_df)[2], " (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)

To leave a comment for the author, please follow the link and comment on their blog: RClimate. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)