在数据框中
df <- data.frame(id = c(12,35), col1 = c("ext", "another"))
如何添加新的列,该列的每一行都包含相同的文本
输出示例
df <- data.frame(id = c(12,35), col1 = c("ext", "another"), mycol = c("mytext","mytext"))
下面应该这样做。
df <- data.frame(id = c(12,35), col1 = c("ext", "another"))
df$mycol <- "mytext"
# id col1 mycol
# 1 12 ext mytext
# 2 35 another mytext
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句