我需要这个:
"X","Y",151,"X","Y",152,"X","Y",153,"X","Y",154,....."X","Y",334
但我只能得到这个:
names<-c("X","Y",seq(152,334,by=1))
#"X","Y",151,152,153,154....334
由于
答案 0 :(得分:1)
我们创建一个序列向量('v1'),用'{1}}'v1'复制向量(c("X", "Y", "")
),用length
“”复制'v1'。
replace the
或者另一个选项是将字符串(v1 <- 152:334
v2 <- rep(c("X", "Y", ""), length(v1))
v3 <- replace(v2, v2 == "", v1)
head(v3, 10)
#[1] "X" "Y" "152" "X" "Y" "153" "X" "Y" "154" "X"
tail(v3, 10)
# [1] "331" "X" "Y" "332" "X" "Y" "333" "X" "Y" "334"
)复制为'{1}}的'v1',"X Y"
复制'v1',将矩阵连接(length
) rbind
,c
将vector
拆分为scan
。
"X Y"