在data.frame中的两列之间添加列 [英] Adding a column between two columns in a data.frame
本文介绍了在data.frame中的两列之间添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
只是一个R初学者,但我认为这也可以:
添加到您的新列中:
df $ d< - list / data
然后你可以重新排序。
df< - df [,c(a,b,d,c)]
I have a data frame that has columns a, b, and c. I'd like to add a new column d between b and c. I know I could just add d at the end by using cbind but how can I insert it in between two columns?
解决方案
Just an R beginner, but I think this also works:
Add in your new column:
df$d <- list/data
Then you can reorder them.
df <- df[,c("a","b","d","c")]
这篇关于在data.frame中的两列之间添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文