xmu_scale_wide_data {umx} | R Documentation |
Scale Wide Data Function
Description
This function scales the values in a wide format data frame and returns a scaled wide format data frame with the same structure as the original, excluding the original non-numeric values.
Usage
xmu_scale_wide_data(data)
Arguments
data |
A data frame with at least two columns. The columns to be scaled should contain numeric values. |
Details
The function first checks if the input is a data frame and that it contains at least two columns. It then adds a row identifier ('row_id') to facilitate reshaping. The data is reshaped to a long format, where the numeric values are scaled using the 'scale' function. After scaling, the function reshapes the data back to wide format. The resultant scaled values replace the original values, and any identifiers or non-numeric columns are removed.
Value
A data frame with the same number of columns as the input data frame, containing the scaled values. The resulting column names will match the original data column names, excluding any non-numeric columns.
See Also
scale
for details on the scaling method used.
Examples
# Example usage
data <- data.frame(
time1 = c(2, 4, 6, 8, 10),
time2 = c(5, 7, 9, 11, 13),
time3 = c(1, 3, 5, 7, 9)
)
scaled_data <- xmu_scale_wide_data(data)
print(scaled_data)