0
目前我有一个循环将一行数据框中的行添加到另一个主数据框中。不幸的是,它将字符转换为数字,但我不想那样。如何获得以下for循环以将一个数据框中的行添加到主数据框中,同时保留字符?在For循环中填充包含字符的数据帧R
AnnotationsD <- data.frame(x = vector(mode = "numeric",
length = length(x)), type = 0, label = 0, lesion = 0)
x = c(1,2)
for(i in length(x)){
D = data.frame(x = i, type = c("Distance"),
label = c("*"), lesion = c("Wild"))
AnnotationsD[[i,]] <- D[[i]]
}
所以我想出来的这个是什么:
x type label lesion
1 1 Distance * Wild
2 2 Distance * Wild
真棒!谢谢user3640617! – albeit2