R 如何将行插入到具有行名称的数据框中?

R 如何将行插入到具有行名称的数据框中?,r,R,这是代码,但我不知道在哪里设置行名 df = data.frame(col1= numeric(0), col2= integer(0)) df = rbind(df,c(1,2)) 我写下我的评论作为回答,这样你可以接受它,如果它满足你的需要 尝试在rbind df = rbind(df,rowname=c(1,2)) 像这样df=rbind(df,rowname=c(1,2))?

这是代码,但我不知道在哪里设置行名

df = data.frame(col1= numeric(0), col2= integer(0))
df = rbind(df,c(1,2)) 

我写下我的评论作为回答,这样你可以接受它,如果它满足你的需要

尝试在
rbind

df = rbind(df,rowname=c(1,2))
像这样
df=rbind(df,rowname=c(1,2))