Remove attributes from data read in readr::read_csv
问题 readr::read_csv adds attributes that don't get updated when the data is edited. For example, library('tidyverse') df <- read_csv("A,B,C\na,1,x\nb,1,y\nc,1,z") # Remove columns with only one distinct entry no_info <- df %>% sapply(n_distinct) no_info <- names(no_info[no_info==1]) df2 <- df %>% select(-no_info) Inspecting the structure, we see that column B is still present in the attributes of df2 : > str(df) Classes ‘spec_tbl_df’, ‘tbl_df’, ‘tbl’ and 'data.frame': 3 obs. of 3 variables: $ A: