LOADING AND PLOTTING THE DATA (Part 1)
Working with hydro-meteorological data can be very time consuming and exhausting. Luckily, R can provide a framework to easily import and process data in order to implement statistical analysis and models. In these tutorials, we are going to explore and analyze data from a tropical basin in order to create a simple forecast model.
Let’s have a look at these exercises and examples.
Answers to these exercises are available here.
Exercise 1
First, let’s import the daily levels of a river and the rainfall data from the basin, stored in a CSV file. Please download the data here (PAICOL.csv) and import it with the function read.csv
.
Then, assign it to river_data
.
Remember that river_data
is a data frame, so we can access the attributes of it with $
; for example, you can get the date values with river_data$DATE
.
Exercise 2
To guarantee that the DATE
column has the proper format, it is crucial to convert the string values into dates with the function as.Date
. Please replace the value of DATE
with formatted dates.
Exercise 3
Create a summary of the river_data
.
- Import data into R in several ways while also beeing able to identify a suitable import tool,
- use SQL code within R,
- And much more.
Exercise 4
Normally we can use the build in R functions; but, this time, we will use the ggplot
package. In my opinion, it is able to create better plots. Before we start, install it and load it to be able to use it.
install.packages("ggplot2")
library(ggplot2)
Create a line plot of the LEVEL
with the ggplot
function.
Exercise 5
Create a scatter plot of the RAIN
against LEVEL
.
Exercise 6
Create a plot of the RAIN
and LEVEL
.
Exercise 7
Find and plot circles on the LEVEL
plot at the maximum and minimum value.
Exercise 8
Plot the LEVEL
for the year “2001.”
I would like to do the exercises, unfortunately, the PAICOL.csv file is not downloadable as I am returned a 404 error 🙁
Hi Fabien, thank you for reporting the error, I fix already the link, please let me know if you are able to download it, Regards
Hello Felipe,
thank you for the upload it works well !
All the best,
Fabien
Hi Fabien, I’m glad that you were able to run the exercise,
Best regards 😀
Felipe