data_reduce: Function for reducing the no. of data points in an X-Y...

View source: R/data_reduce.R

data_reduceR Documentation

Function for reducing the no. of data points in an X-Y dataset

Description

The function
1. Uniformly selects points between the dataset and for the select indexes returns the X and Y values in a dataframe
2. The no. of selected points is reduced by an integer factor "fract"

Usage

data_reduce(X, Y, fract)

Arguments

X

X vector of the original dataset

Y

Y vector of the original dataset

fract

The factor by which the function needs to reduce the size of the data set.
This necessarily needs to be an integer.

Value

The returned value is always a 2-column dataframe with column names 'X' and 'Y'

Note

If the no. of points in the new dataset are one or less, then the function throws an error.

Author(s)

Chitran Ghosal

Examples

t <- seq(0, 2*pi, by=0.0001)
Y <- sin(t)
df <- data_reduce(t,Y, fract = 1000)
par(mfrow = c(2,1))
plot(t,Y, main = 'original data')
plot(df$X, df$Y, main = 'reduced data')
par(mfrow = c(1,1))

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.