View source: R/multiscaleSVDxpts.R
glm_impute | R Documentation |
Impute missing data using GLM models
glm_impute(
dataframe,
columns_to_impute,
predictor_columns,
family = "gaussian"
)
dataframe |
A data frame containing the data to impute. |
columns_to_impute |
A vector of column names to impute. |
predictor_columns |
A vector of column names to use as predictors. |
family |
A string specifying the GLM family (default is 'gaussian'). |
A data frame with imputed values.
set.seed(123)
df <- data.frame(
age = c(25, 30, 35, NA, 45, 50, NA, 40, 35, NA),
income = c(50000, 60000, 70000, 80000, 90000, 100000, 110000, NA, 120000, 130000),
education = c(12, 16, 14, 12, NA, 18, 20, 16, 14, 12)
)
columns_to_impute <- c("age")
predictor_columns <- c( "income", "education")
imputed_data <- glm_impute(df, columns_to_impute, predictor_columns, family = 'gaussian')
print(imputed_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.