peak_picker: Pick peaks in datasets interactively

Description Usage Arguments Value Examples

View source: R/peak_pick.R

Description

'peak_picker()' is an interactive tool (a shinyGadget) for finding peaks in datasets (e.g. a spectrum). After loading the dataset and specifying the columns, you can easily select peaks by clicking on the dataset. The gadget will automatically try to determine the nearest peak to the click and select it. Peaks can be deselected by clicking again.

When you are finished press "Done". The gadget will place a piece of code in your clipboard that you should paste into your script for reproducibility.

Usage

1
peak_picker(df, x, y, find_nearest = TRUE)

Arguments

df

A tibble containing the data to pick peaks in

x

Column containing the x-values

y

Column containing the y-values

find_nearest

If TRUE (the default) the gadget will attempt to find the nearest peak when clicking on a point in the dataset. This is disabled by setting this option to FALSE, in which case the point nearest to the click will be selected.

Value

The original dataset with an additional column "peak", which indicates TRUE/FALSE if the given row is a peak.

Examples

1
2
3
4
5
6
7
8
library(tidyverse)
df <- tibble(x1 = seq(0.1, 25, 0.01), y1 = sin(x1)^2/x1)

peak_picker(df, x1, y1)
df <- df %>% add_peaks(c(108,451,770,1086,1401,1716,2031,2345))

# After adding peaks, the plot from the gadget can be reproduced using plot_peaks()
df %>% plot_peaks(x1, y1)

SPOMAN/osctools documentation built on May 24, 2019, 6:19 p.m.