eemR 1.0.0

When eemR was originally created, I wrote few functions to import eems derived from the spectrofluorometers I knew. Given the high diversity in file formats, eemR now offers the possibility for the user to write his/her own import function. An example In this example, we will learn how to create a import function for a specific eem file generated by the software of a Cary Eclipse spectrofluorometer. First, lets have a look to the content of custom_cary. [Read More]

Extracting Weather Data From Canadian Archive

To me, spring 2019 seems cooler than the last year spring. I wanted to plot daily temperature data for my city. I know that the Government of Canada have such data. The following code was used to extract daily mean temperature for springs 2018 and 2019. library(extrafont) library(tidyverse) library(glue) ## Set default ggplot2 font size and font familly loadfonts(quiet = TRUE) theme_set(theme_bw(base_size = 12, base_family = "Poppins")) The first thing I did was to create a tibble with all the dates for which I wanted to extract the weather information. [Read More]

Introducing gitignore

In this post I will introduce the gitignore R package (https://github.com/PMassicotte/gitignore). Basic idea gitignore is a simple R package that provide an interface to query gitignore.io to fetch gitignore templates that can be included in the .gitignore file. More than 450 templates are currently available. There are actually two functions in the package: gi_available_templates(): to get a list of all templates available on gitignore.io. gi_fetch_templates(): to get one or more template(s). [Read More]

Numerical integration in R

Math 101

Although R in not a symbolic language like Mathematica, Maple or Matlab, it can be used for calculus operations. Letâ€™s get started. For the shake of simplicity, we will integrate the following equation: $f(x) = \cos(x) + 2$ We first define the equation in the form of a function since it is a requirement to use the R integrate function. Then, plot the function curve between 0 and 4. [Read More]

Calculating daylight in R

A little bit more than a year ago I moved in Denmark. So far, the last year has been quite fun and I have been working on interesting projects. The most difficult part has been the winter since the daylight is very short between November and February. I was curious to see what was the difference in daylight between my home country (Canada) and Denmark. This is a short post showing how to calculate daylight based on the latitude position and the day of the year (DOY). [Read More]

R 101

Sometimes when you open a data file (lets say a .csv), variables will be recognized as factor whereas it should be numeric. It is therefore tempting to simply convert the variable to numeric using as.numeric(). Big mistake! If you use directly as.numeric() on a variable of the type factor, R will returns the levels of the factor rather the actual values. To overcome this hassle, you should first convert the variable into a string with as. [Read More]