【问题标题】:How do I extract all the text in a bibliography that is within quotation marks in R?如何提取 R 中引号内的书目中的所有文本?
【发布时间】:2020-11-21 07:44:03
【问题描述】:

我需要从书目列表中提取期刊标题。标题都在引号内。 那么有没有办法让 R 提取括号内的所有文本?

我已将列表作为文本文件读入 R:

"data

以下是列表中的几行:

Andronis,C.E.,Hane,J.,Bringans,S.,Hardy,G.,Jacques,S.,Lipscombe,R.,Tan,K-C。 (2020 年)。 “使用 Dieback 的致病因子 Phytophthora cinnamomi 的蛋白质组学进行基因验证和重塑。” bioRxiv。 DOI:https://doi.org/10.1101/2020.10.25.354530 Beccari, G., Prodi, A., Senatore, M.T., Balmas, V,。 Tini, F., Onofri, A., Pedini, L., Sulyok, M,。 Brocca, L., Covarelli, L. (2020)。 “种植面积影响意大利硬粒小麦中真菌群落和次生代谢物的存在。”毒素https://www.mdpi.com/2072-6651/12/2/97 Corsi, B., Percvial-Alwyn, L., Downie, R.C., Venturini, L., Iagallo, E.M., Campos Mantello, C., McCormick-Barnes, C., See, P.T., Oliver, R.P., Moffat, C.S., Cockram, J. “小麦对来自 Pyrenophora tritici-repentis 的 ToxB 真菌效应物敏感性的遗传分析,棕斑的致病因子” 理论和应用遗传学。 https://doi.org/10.1007/s00122-019-03517-8 Derbyshire, M.C., (2020) 植物病原体正选择压力的生物信息学检测:分子序列进化的中性理论。 (2020) 微生物学前沿。 https://doi.org/10.3389/fmicb.2020.00644 Dodhia, K.N., Cox, B.A., Oliver, R.P., Lopez-Ruiz, F.J. (2020)。 “当时间真的就是金钱时:原位量化小麦病原体 Blumeria graminis f 中的甲氧基丙烯酸酯抗性突变 G143A。 sp。小麦。” bioRxiv,doi:https://doi.org/10.1101/2020.08.20.258921 Graham-Taylor, C., Kamphuis, L.G., Derbyshire, M.C. (2020 年)。 “对广泛宿主范围植物病原真菌核盘菌核盘菌基因组中次生代谢物生物合成簇的详细计算机分析。” BMC基因组https://doi.org/10.1186/s12864-019-6424-4

【问题讨论】:

    标签: r text extract


    【解决方案1】:

    试试这样的:

    library(stringr)
    str_extract_all(x, "“.*?”") %>% .[[1]] 
    

    如果您想从结果中删除引号,请在管道末尾添加:

    str_remove_all("[“”]")
    

    输出:

    [1] "Gene validation and remodelling using proteogenomics of Phytophthora cinnamomi, the causal agent of Dieback."                                                       
    [2] "Cultivation Area Affects the Presence of Fungal Communities and Secondary Metabolites in Italian Durum Wheat Grains."                                               
    [3] "Genetic analysis of wheat sensitivity to the ToxB fungal effector from Pyrenophora tritici-repentis, the causal agent of tan spot"                                  
    [4] "When time really is money: in situ quantification of the strobilurin resistance mutation G143A in the wheat pathogen Blumeria graminis f. sp. tritici."             
    [5] "A detailed in silico analysis of secondary metabolite biosynthesis clusters in the genome of the broad host range plant pathogenic fungus Sclerotinia sclerotiorum."
    

    【讨论】:

    • 谢谢,谢谢。我尝试了代码,但是结果是:character(0)
    • 我刚刚复制了您的文本并将其分配给x,它给了我正确的输出。
    • 我已经复制了您提供的文本并将其分配给 R 中的变量 xx <- ...(当然您需要将文本放在 R 中的引号中)
    • 如何将 str_remove_all("[“”]") 添加到管道的末尾?
    • str_extract_all(x, "“.*?”") %>% .[[1]] %>% str_remove_all("[“”]")
    猜你喜欢
    • 1970-01-01
    • 2020-09-14
    • 2010-09-25
    • 2012-01-26
    • 1970-01-01
    • 1970-01-01
    • 2015-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多