r - 在 R Markdown 中对文章标题进行排序
问题描述
我在 R markdown 中有 50 多个手稿标题,它们是直接从 word 文档中复制而来的。我想知道是否有一个函数或包我可以按字母顺序对这些标题进行排序,这样我就可以在 R markdown 中列出它们。
Hospital admission and mortality rates for non-covid diseases in Denmark during covid-19 pandemic: nationwide population based cohort study
Covid-19 deaths in Africa: prospective systematic postmortem surveillance study
Food anaphylaxis in the United Kingdom: analysis of national data, 1998-2018
Association of first trimester prescription opioid use with congenital malformations in the offspring: population based cohort study
解决方案
在以下示例中,您应该能够将文本复制到 的text
参数中read.table
。sep
定义条目由换行符分隔,并跳过空行 ( blank.lines.skip = T
)
df <- read.table(sep = "\n", blank.lines.skip = T, stringsAsFactors=FALSE,
text = "Hospital admission and mortality rates for non-covid diseases in Denmark during covid-19 pandemic: nationwide population based cohort study
Covid-19 deaths in Africa: prospective systematic postmortem surveillance study
Food anaphylaxis in the United Kingdom: analysis of national data, 1998-2018
Association of first trimester prescription opioid use with congenital malformations in the offspring: population based cohort study"
)
df <- sort(df$V1)
df
# [1] "Association of first trimester prescription opioid use with congenital malformations in the offspring: population based cohort study"
# [2] "Covid-19 deaths in Africa: prospective systematic postmortem surveillance study"
# [3] "Food anaphylaxis in the United Kingdom: analysis of national data, 1998-2018"
# [4] "Hospital admission and mortality rates for non-covid diseases in Denmark during covid-19 pandemic: nationwide population based cohort study"
推荐阅读
- c# - 将字符串 [] 转换为列表
在c#中 - regex - 用 ascii 连字符“-”替换所有连字符类型
- java - 声纳 - 实例化 SimpleDateFormat 对象时,指定区域设置
- python - 如何使用 python 和 PyCharm 生成和绘制三角波?我该如何编码?
- ios - swift 4迁移后的Xcode构建错误
- ruby - Ruby 将 .50 读取为 .5
- postgresql - 7 天退货/保留率
- linq - System.Data.EntityProxies group by 不断进行大量选择 GroupBy linq
- javascript - Javascript 日期:一场噩梦
- java - 如何读取文本文件、处理它并写入 toString()