我有一个CSV文件这样遍历数据帧,并追加到一个新的空单
a b c
1 2 'some string1'
1 54 'some string2'
2 87 'some string3'
3 18 'some string4'
我需要遍历每个数据和复制数据彼此的数据帧。所以我需要这样的东西
df <- read.csv("example.csv", sep='\t', header=TRUE)
new_df <- data.frame(a=NA, b=NA, c=NA)
for (row in df){
#some calculation here then
append(row to new_df)
}
save the new_df to a new csv.
我该怎么做?我找到了很多解决方案,但都让我感到困惑。
'DF = rbind(DF,the.new.row.to.append)' – Onyambu
我认为OP想追加到一个新的空白数据框,而不是原始数据框。 – neilfws