I have an dataframe below, in reality it actually has much more columns, and I´d like to select only last two columns.
df <- read.table(text="
date1 date2 date3
1 NA 2016-12-01 2016-12-01
2 2017-01-01 2018-10-01 2016-12-01
3 2016-12-01 NA 2016-12-01
4 NA NA 2016-12-01
", header=TRUE)
How can I do it without specifying column names?
df %>%
select(date2, date3)
dplyr
too:df[,tail(names(df),2)]
– Inkhorn