## 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]

## Analysis of speaker genders at the 2018 ArcticNet Annual Scientific Meeting

Last week I was participating to the ArcticNet Annual Scientific Meeting 2018 in Ottawa. I was pleasantly surprised to see that there was a large proportion of women present at the conference. After the panel discussion on women in northern science which took place on Thursday night, I decided to see if I could use R to scan the scientific PDF program to determine how many men and women were giving scientific presentations. [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]

If you are like me, chances are that you update RStudio on a daily basis. Here is a small R script that automatically download and install the latest version of RStudio on your computer. Note this is for ubuntu64 based systems, but this can be easily modified for Windows or Mac platforms.

rstudio_ubuntu_daily_url <- "https://www.rstudio.org/download/daily/desktop/ubuntu64/"

file <- regmatches(r, regexpr("https\\S+?deb", r))[1]
file

destfile <- paste("/tmp/", basename(file))

cmd <- sprintf("dpkg -i %s", destfile)
system(cmd)

## Introducing eemR

The eemR package implements various functions used calculate metrics from excitation-emission matrix (EEM) as well as to preform pre-processing corrections before PARAFAC analysis. All functions from this package start with the eem_ prefix. Please note this is a very alpha version of the package for testing purpose only. library(eemR) ## Registered S3 methods overwritten by 'ggplot2': ## method from ## [.quosures rlang ## c.quosures rlang ## print.quosures rlang ls("package:eemR") ## [1] "absorbance" "eem_bind" ## [3] "eem_biological_index" "eem_coble_peaks" ## [5] "eem_cut" "eem_export_matlab" ## [7] "eem_extract" "eem_fluorescence_index" ## [9] "eem_humification_index" "eem_inner_filter_effect" ## [11] "eem_names" "eem_names<-" ## [13] "eem_peaks" "eem_raman_normalisation" ## [15] "eem_read" "eem_remove_blank" ## [17] "eem_remove_scattering" "eem_set_wavelengths" The package can be installed using the following command. [Read More]

## Quick tip

### How to remove elements that are not in a list

It is easy to verify if elements are within a list using the %in% operator in R. For example:

c("a", "b") %in% letters[1:5]
## [1] TRUE TRUE

However, I am often in a situation where I need to do the opposite. This can be easily achieved using the Negate() function.

%ni% <- Negate(%in%)
c("a", "b") %ni% letters[1:5]
## [1] FALSE FALSE

Voilà!

## 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]