如何在使用 colnames 创建包含 R(数据框)中所有 colnames 的列表时建立索引
How to index when using colnames to create a list with all colnames in R(data frames)
我有以下问题:
我需要列表中从 V1 到结尾 V200 的所有列名称,但我不知道如何以及在何处将索引插入到这些代码行中。
像这样,它给了我所有列名的列表,但我不需要前两个。请帮忙,谢谢!
enter image description here
更新,再次感谢akrun提供better/shorter解决方案:
names(df)[3:ncol(df)]
对于dataframes不需要使用colnames
,和names
一样。 The difference is only in case you're dealing with matrices
我有以下问题:
我需要列表中从 V1 到结尾 V200 的所有列名称,但我不知道如何以及在何处将索引插入到这些代码行中。 像这样,它给了我所有列名的列表,但我不需要前两个。请帮忙,谢谢!
enter image description here
更新,再次感谢akrun提供better/shorter解决方案:
names(df)[3:ncol(df)]
对于dataframes不需要使用colnames
,和names
一样。 The difference is only in case you're dealing with matrices