clean_data | R Documentation |
Clean Data by Interpolating Missing Values
clean_data(data, n_trials, n_replicates)
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. |
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.
A cleaned data frame with missing values interpolated.
find_next_good_datapoint
for details on the interpolation process.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.