我试图编织降价时遇到问题 . 当我运行以下代码时:

matchlist <- data.frame(LIST) %>%
             group_by(school) %>%
             filter(match_score == min(match_score))

我收到以下错误:

grouped_df_impl(data,unname(vars),drop)中的错误:列testscore是不受支持的类型NULL调用:... group_by.data.frame - > grouped_df - > grouped_df_impl - > .Call

“testscore”是数据框LIST中的另一列,当我运行此块时,不会发生此错误 . 我注意到的另一件事是,当我运行上面的代码时,我在匹配列表上附加了一堆“attr”,并且匹配列表的类是

> class(matchlist)
  [1] "grouped_df" "tbl_df"     "tbl"        "data.frame"

而不仅仅是“data.frame” .

“LIST”的简化结构是:

code    school    testscore    match_score
   1       aaa          aaa              0
   1       aaa          aba          0.211
   1       aaa          bba          0.544
   2       bbb          bvv          0.888
   2       bbb          bbd          0.015
   3       ccc          sss          0.899
   ...     ...          ...            ...

我通过使用testscore为每个学校做了成对,并进行了模糊匹配(匹配得分是最后一列) . 我正在尝试为每个学校选择最佳分数(最小),因此我将其按学校名称分组并尝试制作匹配列表 .

如果你能帮助我解决这个问题,我将不胜感激 .


这是输出结果 .

> dput(droplevels(head(LIST, 4)))
structure(list(code = c(102, 102, 102, 104), school = c("UNIVERSITY OF AAA", 
"UNIVERSITY OF AAA", "UNIVERSITY OF AAA", 
"BBB COLLEGE"), testscore = c("UNIVERSITY OF AAA", 
"UNIVERSITY OF SOUTH AAA", "AAA COLLEGE", 
"UNIVERSITY OF AAA SCHOOL"), match_score = c(0.0797101449275361, 
0.194990021076978, 0.366802437561176, 0.46046176046176)), .Names = c("code", 
"school", "testscore", "match_score"), row.names = c(NA, 4L), class = 
"data.frame")