• R/O
  • SSH

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版fb6dbc5e9111c1e79844e23177bc496b760d29e2 (tree)
时间2020-09-19 05:49:07
作者Lorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

I had saved the wrong solution!

更改概述

差异

diff -r b7ba4a84b1ac -r fb6dbc5e9111 R-codes/test_summary.R
--- a/R-codes/test_summary.R Fri Sep 18 22:47:12 2020 +0200
+++ b/R-codes/test_summary.R Fri Sep 18 22:49:07 2020 +0200
@@ -14,10 +14,9 @@
1414
1515 ## See https://stackoverflow.com/questions/63959015/dplyr-and-summarising-according-to-presence-or-not-of-an-element
1616
17-
1817 df_summary <- df %>%
19- distinct(year) %>%
20- anti_join(has_d, by = "year") %>%
21- mutate(ranking = -1L) %>%
22- bind_rows(has_d) %>%
23- arrange(year)
18+ mutate(is_d = (x=="d")*1) %>%
19+ group_by(year) %>%
20+ summarise(Val=if_else(sum(is_d)==1,
21+ sum(is_d*ranking),
22+ -1))