R 在每行中创建一个具有特定字符串的新列
在数据帧中R 在每行中创建一个具有特定字符串的新列,r,R,在数据帧中 df <- data.frame(id = c(12,35), col1 = c("ext", "another")) df下面的步骤应该可以完成 df <- data.frame(id = c(12,35), col1 = c("ext", "another")) df$mycol <- "mytext" # id col1 mycol # 1 1
df <- data.frame(id = c(12,35), col1 = c("ext", "another"))
df下面的步骤应该可以完成
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
df我们也可以利用回收
data.frame(id = c(12,35), col1 = c("ext", "another"), mycol = "mytext")
data.frame(id = c(12,35), col1 = c("ext", "another"), mycol = "mytext")