remove_duplicate_indices.RdThis function removes columns from a data frame that are considered duplicate indices, except for the column named "ID". A column is considered a duplicate index if all its values are unique and the number of unique values equals the number of rows in the data frame.
remove_duplicate_indices(x)A data frame containing only the "ID" column and other columns that are not duplicate indices.
df <- data.frame(
ID = c(1, 2, 3),
col1 = c(1, 2, 3),
col2 = c("A", "B", "C"),
col3 = c(1, 1, 1)
)
remove_duplicate_indices(df)
#> ID col3
#> 1 1 1
#> 2 2 1
#> 3 3 1