选择第2列到R中的最后一列 [英] Select column 2 to last column in R
本文介绍了选择第2列到R中的最后一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,
newdata< - olddata [,2:10]
是否有最后一列的默认符号,因此我不必计算所有列?
我试过
newdata< - olddata [,2:]
但没有起作用。
解决方案
我认为最好专注于想要摆脱一列数据,而不想选择每一列。你可以这样做@Arun建议:
olddata [, - 1]
或:
olddata $ ColNameToDelete& NULL
I have a data frame with multiple columns. Now, I want to get rid of the row.names column (column 1), and thus I try to select all the other columns.
E.g.,
newdata <- olddata[,2:10]
is there a default symbol for the last column so I don't have to count all the columns? I tried
newdata <- olddata[,2:]
but it didn't work.
解决方案
I think it's better to focus on wanting to get rid of one column of data and not wanting to select every other column. You can do this as @Arun suggested:
olddata[,-1]
Or:
olddata$ColNameToDelete <- NULL
这篇关于选择第2列到R中的最后一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文