R-CMD-check Lifecycle: stable CRAN status

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

ftirsr

The goal of ftirsr is to help easily create a Partial Least Squares Regression model to estimate composition of natural compounds such as Biogenic Silica (BSi) and Total Organic Carbon in lake sediment core samples. This package aids a user in eliminating the difficulties of loading and cleaning cumbersome samples into R, and allows a user to predict BSi content in their samples without Wet Chemistry data.

Installation

The development version from GitHub can be accessed like so:

``` {r, eval = FALSE} remotes::install_github("sds270-s22/ftirsr")

## Examples

```r
library(ftirsr)
library(tidyverse)
library(pls)

# This shows finding the maximum biogenic silica percentage in the dataset
max(greenland$bsi)
# This shows how to easily read a directory of FTIRS samples into R while attaching Wet Chemistry values and interpolating onto a vector of rounded wavenumbers for ease of interpretation

my_data <- read_ftirs(dir_path = "~/ftirsr/tests/testthat/test_samples",
                      wet_chem_path = "~/ftirsr/tests/testthat/wet-chem-data.csv")

head(my_data)
 # This shows pivoting the ftirs dataframe to the wide format necessary to run in a PLS model
my_data_wide <- my_data %>%
  pivot_wider() %>%
  # We shouldn't include BSi col in prediction
  select(-1)

# Showing the first 5 columns and the first 10 rows
head(my_data_wide[1:5], 10)
# It is just as easy to pivot back
# Wet Chem data is included, so we denote that with wet_chem = TRUE
my_data_long <- my_data_wide %>%
  pivot_longer(wet_chem = TRUE)

head(my_data_long)
# We can confirm that this object is class `ftirs`, which is necessary to access methods, such as predict.ftirs()
is.ftirs(my_data_wide)
# It is easy to predict the amount of Biogenic Silica in your sample using our model that is trained on 131 arctic lake sediment core samples
preds <- predict(my_data_wide)
preds

For more usage, please see our vignette.



sds270-s22/ftirsr documentation built on June 24, 2022, 12:56 p.m.