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

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)

This entry was posted in R and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s