【发布时间】:2021-12-17 19:15:52
【问题描述】:
【问题讨论】:
-
请不要发布数据或代码的照片!如果您这样做,愿意帮助您的人将不得不输入所有这些文本。而是提供minimal reproducible example这里是a good overview on how to ask a good question
-
是的,请注意!谢谢你的建议!
【问题讨论】:
我同意 cmets 中的 dario,但使用 group_by 和 paste 很容易解决:
library(tidyverse)
cont <- tibble(
ticker = c(rep('000001-SHE', 6), '000002-SHE', rep('000046-SHE', 2)),
cont_name = c('Bribery and Corruption', 'Business Ethics', 'Corporate Governance', 'Quality and Safety', 'Social Impacts of Products', 'Carbon Impacts of Products', 'Quality and Safety', 'Business Ethics', 'Labour Relations')
)
cont %>%
group_by(ticker) %>%
summarize(cont_name = paste(cont_name, collapse = ','))
【讨论】: