Description Usage Arguments Details Value Examples
Adds an new entry to an existing colleciton object.
1 2 3 4 5 6 7 8 9 10 11 12 | add_spectrum(x, ...)
## S3 method for class 'collection'
add_spectrum(
x,
values,
left,
right,
id = deparse(substitute(values)),
label = NA,
...
)
|
x |
A |
... |
further arguments passed to or from other methods(not currenctly used). |
values |
A vector of intensity values. |
left |
A dbl, left limit of the spectra, corresponds to the
first element of |
right |
A dbl, right limit of the spectra, corresponds to the
last element of |
id |
A unique identifier for the sample. |
label |
A label for the sample. |
It is assumed that the binning is uniform and correspond to point measurments.
Be careful with the values of leftand right! THis is important
for example for NMR data which are usually given with a reversed
y-axis.
labels should be used to provide meanigful labels to the samples, e.g.
'treated' and 'control'.
It is recommended to populate a collection using purrr::walk
on a list of files (see example).
An updated version of x.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ####################################################################
# A simple example: adding a spectra from a vector of values:
library(tidySpectR)
# Genearating some values
values = runif(50)
left = 0
right = 49
# Collection is empty on creation
coll = collection()
# Adding the data
coll %>%
add_spectrum(values, left, right, id = "basic_example", label = "test")
####################################################################
## Not run:
# Real life example: parsing data form file and adding them to a
# collection on the fly
library(purrr)
# Generate a list of file paths for a folder containing spectra data files
folder_path <- "path/to/data/folder"
files <- file.path(folder_path, list.files(folder_path))
# Create a collection and add the spectra
coll <- collection()
purrr::walk(files,
function(x){
# Parse your files to extract values, limits and ids
# ...
coll <<- coll %>%
add_spectrum(values, left, right, id)
})
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.