Learn R Programming

forceR (version 1.0.20)

rescale_peaks: Rescale Peaks

Description

Rescales time series in x and y to values ranging from 0 to 1.

Usage

rescale_peaks(
  df.peaks,
  df.data,
  plot.to.screen = FALSE,
  path.data = NULL,
  show.progress = FALSE
)

Value

This function returns a tibble in the same format as df, but with the additional columns t.norm and force.norm which will contain the rescaled time and force data both ranging from 0 to 1.

Arguments

df.peaks

The resulting tibble of the function find_strongest_peaks(). See ?find_strongest_peaks for more details.

df.data

A data frame or tibble in the below format. The columns t (time), force and measurement (measurement ID) must be present. This will usually be the same table that was used before in find_strongest_peaks().

plot.to.screen

A logical value indicating if results should be plotted in the current R plot device. Default: FALSE.

path.data

A string character defining where to save the results. If NULL, data will not be saved to disk. Default: NULL.

show.progress

A logical value indicating if progress should be printed to the console. Default: FALSE.

Details

df.peaks at least needs to contain the following columns:

speciesmeasurementsstartsends
species.1measurements.1starts.1ends.1
............
species.nmeasurements.nstarts.mends.m

Check forceR::peaks.df to see an example tibble.

df.data at least needs to contain the following columns:

tforcemeasurement
t.1force.1measurement.1
.........
t.nforce.nmeasurement.m

Check forceR::df.all.200.tax to see an example tibble.

Examples

Run this code
# Using the forceR::df.all.200.tax and forceR::df.all.200.tax datasets:

# rescale bites
peaks.df.norm <- rescale_peaks(df.peaks = forceR::peaks.df,
                               df.data = forceR::df.all.200.tax,
                               plot.to.screen = FALSE,
                               path.data = NULL,
                               show.progress = FALSE)


# maximum values of time and force both range from 0 - 1:
range(peaks.df.norm$t.norm)
range(peaks.df.norm$force.norm)

Run the code above in your browser using DataLab