【问题标题】:paste some character vectors into one string in R将一些字符向量粘贴到 R 中的一个字符串中
【发布时间】:2022-10-20 20:52:57
【问题描述】:

例如,我有一个字符向量:

x = c("a","b","c")

和另一个类似的字符串:

y = "The alphabet starts with"

当我做

paste(y,x)

我明白了

[1] "The alphabet starts with a" "The alphabet starts with b"
[3] "The alphabet starts with c"

但我想得到的是:

[1] "The alphabet starts with a b c"

我如何设法得到这个?

【问题讨论】:

    标签: r string paste


    【解决方案1】:
    paste(y, paste(x, collapse = " "))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-07
      • 2015-07-19
      • 2015-11-27
      • 2011-10-22
      • 2021-09-14
      • 2014-10-28
      • 1970-01-01
      相关资源
      最近更新 更多