Student_1899
Student_1899

Reputation: 19

How to index when using colnames to create a list with all colnames in R(data frames)

I have a problem regarding the following issue:

I need all columnames aport from V1 till the end V200 in a list, but I don't know how and where to insert the index into these lines of code. Like this, it gives me a list of all columnames but I don't need the first two. Please help, thank you!

enter image description here

Upvotes: 0

Views: 37

Answers (1)

Marco_CH
Marco_CH

Reputation: 3294

Update, once more, thanks to akrun for a better/shorter solution:

names(df)[3:ncol(df)]

For dataframes there is no need to use colnames, it's the same like names. The difference is only in case you're dealing with matrices

Upvotes: 1

Related Questions