我有一个数据集df,里边有重复的列名“depth”,我想用filter筛选其中一些行,
filter(df,result=="Ⅰ")
报错,提示depth不能复制。
Error: Column names depth
, depth
must not be duplicated.
Use .name_repair to specify repair.
Run rlang::last_error()
to see where the error occurred.
rlang::last_error()
<error/rlang_error>
Column namesdepth
,depth
must not be duplicated.
Use .name_repair to specify repair.
Backtrace:
- dplyr::filter(tmp, result == "Ⅰ")
- dplyr:::filter.data.frame(tmp, result == "Ⅰ")
- dplyr::tbl_df(.data)
- tibble:::as_tibble.data.frame(data, .name_repair = "check_unique")
- tibble:::as_tibble.list(unclass(x), ..., .rows = .rows, .name_repair = .name_repair)
- tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x))
- tibble:::set_repaired_names(x, .name_repair)
- tibble:::repaired_names(names(x), .name_repair = .name_repair)
- tibble:::check_unique(new_name)
Runrlang::last_trace()
to see the full context.
当然这个有变通办法,df[df$result=="Ⅰ",]是可以达到我要的目的的,但是不能用filter这种舒服的方法,总是憋得难受,如果我不想去处理df的数据集的重复列,filter就不能用吗?