Data-sets often arrive to us in a form that is different from what we need for our modeling or visualization functions, which, in turn, don’t necessarily require the same format. Reshaping data.frames is a step that all analysts need, but many struggle with. Practicing this meta-skill will, in the long-run, result in more time to […]

## Non-Linear Models in R: Exercises

A mechanistic model for the relationship between x and y sometimes needs parameter estimation. When model linearisation does not work,we need to use non-linear modeling. There are three main differences between non-linear and linear modeling in R: 1. Specify the exact nature of the equation. 2. Replace the lm() with nls(), which means non-linear least […]

## Intro To Time Series Analysis – Part 2: Exercises

In the exercises below, we will explore more in the Time Series analysis. The previous exercise can be found here. Please follow this in sequence. Answers to these exercises are available here. Exercise 1 Load the AirPassengers data. Check its class and see the start and end of the series. Exercise 2 Check the cycle of […]

## How To Create a Flexdashboard: Exercises

INTRODUCTION With flexdashboard, you can easily create interactive dashboards for R. What is amazing about it is that with R Markdown, you can publish a group of related data visualizations as a dashboard. Additionally, it supports a wide variety of components, including htmlwidgets; base, lattice, and grid graphics; tabular data; gauges and value boxes […]

## Sharpening The Knives in The data.table Toolbox: Exercises

If knowledge is power, then knowledge of data.table is something of a super power, at least in the realm of data manipulation in R. In this exercise set, we will use some of the more obscure functions from the data.table package. The solutions will use set(), inrange(), chmatch(), uniqueN(), tstrsplit(), rowid(), shift(), copy(), address(), setnames() […]

## How To Create a Flexdashboard

INTRODUCTION With flexdashboard, you can easily create interactive dashboards for R. What is amazing about it is that with R Markdown, you can publish a group of related data visualizations as a dashboard. Additionally, it supports a wide variety of components, including htmlwidgets; base, lattice, and grid graphics; tabular data; gauges and value boxes and […]

## Polynomial Model in R – Study Case: Exercises

It is pretty rare to find something that represents linearity in the environmental system. The Y/X response may not be a straight line, but humped, asymptotic, sigmoidal or polynomial are possibly, truly non-linear. In this exercise, we will try to take a closer look at how polynomial regression works and practice with a study case. […]

## Intro To Time Series Analysis – Part 1: Exercises

In the exercises below, we will work with Time Series analysis and see how R can make your life easier when working with Time Series. This will be a series of Exercises and I urge you to take it in series. Please install the package and load the library before starting. Answers to these exercises […]

## How To Plot With Patchwork: Exercises

INTRODUCTION The goal of patchwork is to make it simple to combine separate ggplots into the same graphic. It tries to solve the same problem as gridExtra::grid.arrange() and cowplot::plot_grid, but using an API that incites exploration and iteration. Before proceeding, please follow our short tutorial. Look at the examples given and try to understand the […]

## How To Plot With Patchwork

INTRODUCTION The package patchwork is beeing used to as a connector between different ggplots. More specifically it display them in one picture. Installation You can install patchwork from github with: # install.packages(“devtools”) devtools::install_github(“thomasp85/patchwork”) Its usage is quite straighforward if you already know the how to use ggplot2. library(ggplot2) library(patchwork) p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) […]