tidy.nmr_dataset_1D: Get a tidy data frame from nmr_data object

View source: R/plots.R

tidy.nmr_dataset_1DR Documentation

Get a tidy data frame from nmr_data object

Description

This dataframe is useful for plotting with ggplot, although it may be very long and therefore use a lot of RAM.

Usage

## S3 method for class 'nmr_dataset_1D'
tidy(
  x,
  NMRExperiment = NULL,
  chemshift_range = NULL,
  columns = character(0L),
  matrix_name = "data_1r",
  axis_name = "axis",
  ...
)

Arguments

x

an nmr_dataset_1D object

NMRExperiment

A character vector with the NMRExperiments to include. NULL means all.

chemshift_range

range of the chemical shifts to be included. Can be of length 3 to include the resolution in the third element (e.g. c(0.2, 0.8, 0.005))

columns

A character vector with the metadata columns to get, use NULL to get all of them.

matrix_name

A string with the matrix name, typically "data_1r"

axis_name

A string with the axis name, for now "axis" is the only valid option

...

Ignored

Value

A data frame with NMRExperiment, chemshift, intensity and any additional column requested

Examples

dir_to_demo_dataset <- system.file("dataset-demo", package = "AlpsNMR")
dataset <- nmr_read_samples_dir(dir_to_demo_dataset)
dataset_1D <- nmr_interpolate_1D(dataset, axis = c(min = -1.0, max = 1.6, by = 2.3E-4))
dummy_metadata <- system.file("dataset-demo", "dummy_metadata.xlsx", package = "AlpsNMR")
NMRExp_SubjID <- readxl::read_excel(dummy_metadata, sheet = 1)
dataset_1D <- nmr_meta_add(dataset_1D, NMRExp_SubjID)
df_for_ggplot <- tidy(dataset_1D, chemshift_range = c(1.2, 1.4), columns = "SubjectID")
head(df_for_ggplot)

sipss/AlpsNMR documentation built on Aug. 13, 2024, 5:11 p.m.