Oceanographic Data with R: Plot NEPTUNE Canada Data

by Allan Roberts

This tutorial shows you how to plot data, available from the NEPTUNE Canada website  (www.neptunecanada.com), with the statistical application R. R is free software, and can be downloaded from the R Project site (www.r-project.org/). For this tutorial I will assume that you are familiar with the basics of RFolger Deep bottom pressure

Step 1. Download a CSV file

1.1 Go to the NEPTUNE Canada website:

NEPTUNE headerhttp://www.neptunecanada.com

1.2 Click on “DATA & TOOLS”:

Data & Tools

1.3 Click on “open an account”. You will need an e-mail address, and have to make up a password:Open account

1.4 From the “DATA & TOOLS” page, click on “Data Search”:Data Search

1.5 You need to choose a data source. Click on the “+” sign next to the Folger location:Folger data source

1.6 Click on the “+” sign next to “Folger Deep”:Data source

1.7 Click on the “CTD” for the conductivity-temperature-density sensor:CTD selection

1.8 Click on “Next >>”:Next button

1.9 Set “Date From (UTC)” to September 1, 2012, 00:00:00.Date from

1.10 Set “Date To (UTC)” to September 2, 2012, 00:00:00.Date to

1.11 For “Subsample Type”, choose “Minute”:Subsample type

1.12 Under “Time Series Scalar Data”, click next to “Pressure” in the column for “CSV”:Time series scalar data download

1.13 Click on “+ Add to Cart”:Add to cart

1.14 Click on “Next >>”:Next button

1.15 Click on “Checkout”:Checkout

1.16 Wait …

1.17 Click on “Folger_FolgerDeep_CTD_Pressure_201209.csv” to download it:Download csv

1.18 Create a folder on your desktop called “NEPTUNE data”, and drop the downloaded CSV into the “NEPTUNE data” folder:Create NEPTUNE folder

1.19 For convenience, re-name the file “Folger Deep Pressure.csv”:

Rename file

Step 2. Read the CSV file into R

 2.1 In the R console type “getwd( )”. This will tell you what your current working directory is:getwd working directory

2.2 If you are on a Mac click on “Misc”, and choose “Change Working Directory”:mac wd

If you are on a PC, click on “File”, and choose “Change dir …”:pc wd

2.3 If you are on a Mac, browse for the “NEPTUNE data” folder, click on it, and click on “Open”; if you are on a PC browse for the “NEPTUNE data” folder, click on it, and click on “OK”.mac choose folder

2.4 In the R console, type “getwd( )”; the “NEPTUNE data” folder should now be your working directory:console view of new wd

2.5 Read the CSV file into R, using the “read.csv” function. (The arrow symbol is a combination of the less than sign, ‘<’, and the minus sign, ‘-‘.)read csv

2.6 Type “head(data)” to take a look at the first few lines of data:head(data)

2.7 Type “names(data) <- c(“time”, “pressure”)”.

names(data)

2.8 Type “head(data)” again. Now the columns should have names:head(data) again

2.9 To see all the data, simply type “data” and press “enter.”

 

Step 3. Plot the Data

 3.1 Now plot the data:plot data

3.2 To plot the data as a line graph, with labeled axes, type:line graph

3.3 Add a title:Add title

Citations

NEPTUNE Canada, 2012. Website. Accessed Sept. 26, 2012: www.neptunecanada.com

R Core Team (2012). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria.

Advertisements

4 thoughts on “Oceanographic Data with R: Plot NEPTUNE Canada Data

  1. Pingback: How to Plot VENUS Network Data with R | BMSC Student Blog

  2. Pingback: Fractal Graphics with R: Part 2 | BMSC Student Blog

  3. Hi there! Someone in my Myspace group shared this site with us so
    I came to take a look. I’m definitely enjoying the information. I’m bookmarking and will be
    tweeting this to my followers! Great blog and excellent design and style.

  4. Pingback: Citizen scientist spots a hungry elephant seal in Barkley Canyon | The Madreporite

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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