How to tell R/Shiny to select columns starting from specific column until end ?

Although it seems similar question but it isn't

Select the data from particular column until end i.e delete everything to the left of the data.
But this particular column appears at different column indices

Therefore, simple approaches as below doesn't work

Select based on numbers

iris [,4:ncol(iris)]




Since the Petal.Width can appear at any column position, it is must to use column names.

Is there any efficient way to tell to R,
How to select from Petal.Width until end of the columns irrespective of which column indices it appears ?

Both these work:

select(iris, Petal.Width:colnames(iris)[ncol(iris)])
irisDT <-
irisDT[, Petal.Width:ncol(irisDT)]

There may be more elegant versions.

1 Like

Thanks for elegant solutions :slight_smile:
