This 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)

Arguments

x

A data frame from which duplicate index columns will be removed.

Value

A data frame containing only the "ID" column and other columns that are not duplicate indices.

Examples

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