knitr::opts_chunk$set(
  collapse = TRUE,
  comment = NA
)

Our objective is to compute the maximum intensity from selected elements from a penepma simulation of C-coated EagleXG glass. We have two functions: one reports the maximum primary intensity and the second reports the maximum total intensity.

Load the intensity file

First we get our example file stored in the package.

spcPath <- system.file("extdata", "pe-intens-01.dat", package = "rpenepma")
spcPath

Convert the data to a convenient form

We create a tibble using the penepma_get_intensities function.

library(rpenepma)
tib <- penepma_get_intensities(spcPath)

Ask some key questions

  1. How many transitions do we have?
print(nrow(tib))
  1. What values are reported.
print(names(tib))

Now we can make some useful computations...

Compute the maximum primary intensities for key elements

C.p  <- penepma_get_max_primary_intensity_z(tib, 6)
Si.p <- penepma_get_max_primary_intensity_z(tib, 14)
O.p  <- penepma_get_max_primary_intensity_z(tib, 8)
Ca.p <- penepma_get_max_primary_intensity_z(tib, 20)

Compute the maximum total intensities for key elements

C.t <- penepma_get_max_total_intensity_z(tib, 6)
Si.t <- penepma_get_max_total_intensity_z(tib, 14)
O.t <- penepma_get_max_total_intensity_z(tib, 8)
Ca.t <- penepma_get_max_total_intensity_z(tib, 20)

Create a summary report with two tables

First, the primary intensity. Note that penepma does not report the SNR for the transitions, but we can easily compute and append the value. The *_intensity_z functions do this.

primInt <- dplyr::bind_rows(C.t, Si.t, O.t, Ca.t)
print(primInt)

Prepend a sample ID

primInt <- prepend_sample_id_max_int_tib(primInt, "Eagle-XG")
print(primInt)

Followed by the total intensity

totInt <- dplyr::bind_rows(C.t, Si.t, O.t, Ca.t)
print(totInt)

Prepend a sample ID

totInt <- prepend_sample_id_max_int_tib(totInt, "Eagle-XG")
print(totInt)


jrminter/rpemepma documentation built on May 29, 2019, 11:43 a.m.