Another R blog
https://pmassicotte.github.io/
Recent content on Another R blogHugo -- gohugo.iopmassicotte@hotmail.com (Philippe Massicotte)pmassicotte@hotmail.com (Philippe Massicotte)Fri, 11 May 2018 00:00:00 +0000Numerical integration in R
https://pmassicotte.github.io/post/numerical-integration-in-r/
Fri, 11 May 2018 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/numerical-integration-in-r/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.
https://pmassicotte.github.io/page/publication/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/page/publication/[1] E. Asmala, L. Haraguchi, H. H. Jakobsen, P. Massicotte and J. Carstensen. “Nutrient availability as major driver of phytoplankton-derived dissolved organic matter transformation in coastal environment”. In: Biogeochemistry 137.1-2 (Jan. 2018), pp. 93-104. ISSN: 0168-2563. DOI: 10.1007/s10533-017-0403-0.
[2] L. P. M. Brandão, L. S. Brighenti, P. A. Staehr, E. Asmala, P. Massicotte, D. Tonetta, F. A. R. Barbosa, D. Pujoni and J. F. Bezerra-Neto. “Distinctive effects of allochthonous and autochthonous organic matter on CDOM spectra in a tropical lake”.About me
https://pmassicotte.github.io/page/about/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/page/about/As a numerical ecologsist, the R statistical computing language is an important part of my daily work flow. I mainly use R for environmental modeling and data manipulation. In this not-so-serious blog I will present my recent R work as well as basic tips and tricks about R.
Current research I am currently working as a research associate at the Takuvik Joint International Laboratory under the supervision of Dr. Marcel Babin.Calculating daylight in R
https://pmassicotte.github.io/post/2015-11-06-daylight/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/2015-11-06-daylight/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).Installing latest version of RStudio from R
https://pmassicotte.github.io/post/2016-11-18-updating-rstudio/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/2016-11-18-updating-rstudio/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/" r <- readLines(curl::curl(rstudio_ubuntu_daily_url)) file <- regmatches(r, regexpr("https\\S+?deb", r))[1] file destfile <- paste("/tmp/", basename(file)) download.file(file, destfile = destfile) cmd <- sprintf("dpkg -i %s", destfile) system(cmd) Introducing eemR
https://pmassicotte.github.io/post/2015-11-05-eemr/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/2015-11-05-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) 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.Publications
https://pmassicotte.github.io/page/publication/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/page/publication/[1] E. Asmala, L. Haraguchi, H. H. Jakobsen, P. Massicotte and J. Carstensen. “Nutrient availability as major driver of phytoplankton-derived dissolved organic matter transformation in coastal environment”. In: Biogeochemistry 137.1-2 (Jan. 2018), pp. 93-104. ISSN: 0168-2563. DOI: 10.1007/s10533-017-0403-0.
[2] L. P. M. Brandão, L. S. Brighenti, P. A. Staehr, E. Asmala, P. Massicotte, D. Tonetta, F. A. R. Barbosa, D. Pujoni and J. F. Bezerra-Neto. “Distinctive effects of allochthonous and autochthonous organic matter on CDOM spectra in a tropical lake”.Quick tip
https://pmassicotte.github.io/post/2016-03-07-not_in/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/2016-03-07-not_in/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
https://pmassicotte.github.io/post/2015-11-13-r-101/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/2015-11-13-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.Visualizating olympics medals in R
https://pmassicotte.github.io/post/2016-08-25-olympics2016/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/2016-08-25-olympics2016/Recently I have been more interested to perform web scraping to extract public data to perform data analysis. There are probably many R packages out there that do a good job at such task, but I found out that the rvest was among the most popular ones. Hence I decided to give it a try.
In this post, I’m using the rvest library to visualize how many medals were obtained by each country during the summer Olympics 2016.eemR 0.1.3 is now on CRAN
https://pmassicotte.github.io/post/2016-05-02-eemr-0.1.3/
Mon, 01 Jan 0001 00:00:00 +0000pmassicotte@hotmail.com (Philippe Massicotte)https://pmassicotte.github.io/post/2016-05-02-eemr-0.1.3/eemR has been updated to v0.1.3 and brings a lot of new features. Among the most interesting ones:
Shiny support: You can interactively visualize EEMS by using interactive = TRUE. Ex.: plot(X, interactive = TRUE).
A vignette has been added.
eem_remove_blank() and eem_raman_normalisation() can now try to implicitly use a blank eem from a eemlist object (#20). If blank is omitted (blank = NA), the functions will try to extract the blank from the eemlist object.