如何汇总数据帧中复制行的特定列?

时间:2019-04-04 11:59:49

标签: r dataframe

我有一个包含许多重复行的数据框。我想总结复制行的最后一列,并同时删除复制。谁能告诉我该怎么做? 示例在这里:

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules" -name "." -value @{name='RedirectDefaultDocument';stopProcessing='True'}
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='RedirectDefaultDocument']/match" -name "url" -value "^$"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='RedirectDefaultDocument']/action" -name "url" -value "owa/"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='RedirectDefaultDocument']/action" -name "appendQueryString" -value "False"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='RedirectDefaultDocument']/action" -name "redirectType" -value "Temporary"

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='RedirectDefaultDocument']/action" -name "type" -value "Redirect"

衷心感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

尝试:

library(dplyr)
df %>%
  group_by(name, position) %>%
  summarise(score = sum(score, na.rm = T))