Learn R Programming

profrep (version 1.0.0)

clean_data: Clean Data by Interpolating Missing Values

Description

Clean Data by Interpolating Missing Values

Usage

clean_data(data, n_trials, n_replicates)

Value

A cleaned data frame with missing values interpolated.

Arguments

data

A data frame containing the dataset to be cleaned.

n_trials

The total number of rows in the dataset.

n_replicates

The total number of replicate columns in each row.

Details

This function cleans a dataset by interpolating missing values in the replicate columns of each row using neighboring values. If the data frame ends in null values (the last columns are nulls), it will extrapolate from the last value. If the first value is null, it will loop around and pull from the last replicate to perform the interpolation between the last replicate and the second replicate.

See Also

find_next_good_datapoint for details on the interpolation process.

Examples

Run this code
my_data <- matrix(
   c(
     1, 60, 1, 2, 3, 4, 5,   # No NA values
     1, 90, 9, NA, 4, NA, 2,  # NA Values in row
     1, 120, 3, 6, NA, NA, 9  # Consecutive NA values
    ),
    nrow = 3,
    byrow=TRUE
 )
cleaned_data <- clean_data(my_data, n_trials = 3, n_replicates = 5)
print(my_data)
print(cleaned_data)

Run the code above in your browser using DataLab