【问题标题】:creating new vector of different strings [duplicate]创建不同字符串的新向量[重复]
【发布时间】:2018-09-12 06:47:10
【问题描述】:

R 新手,所以不太确定我在看什么,但我想 purrr 可以为我做到这一点。

我怎样才能创建这个向量:

c <- c("cookie", "cookie", "cookie", "cookie", "dog", "dog", "dog")

从此:

a <- 4
b <- 3

【问题讨论】:

  • 你需要rep(c("cookie", "dog"), c(4, 3))吗?
  • 是的,很快,谢谢!

标签: r


【解决方案1】:

使用rep

rep(c("cookie","dog"),c(a,b))

【讨论】:

    猜你喜欢
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 2012-06-13
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多