Quick question - How to convert all (or some: e.g. cols=1:5
) columns at once (in one line) to another type (lets say integer), using dplyr
.
A data to play with: df <- diamonds %>% slice(1:3) %>% select (5:10)
NB:
I know how to do it in data.table
:
dt <- df %>% data.table;
cols=1:5
dt[ , (cols):=lapply(.SD, as.integer), .SDcol=cols]