construct_cols | R Documentation |
This function mostly exists so that I don't have to keep typing df[2:length(df)]
or
some other variant of it. It lets me subset columns based on contiguous or
non-contiguous ranges.
construct_cols(df, from = 1, to = NULL, cols = NULL)
df |
(Dataframe) A dataframe. |
from, to |
(Numeric or |
cols |
(Numeric or |
A numeric vector that can be used to reference columns in df
.
## Not run:
cols <- construct_cols(mtcars, from = 7)
cols
#> [1] 7 8 9 10 11
mtcars[cols]
#> qsec vs am gear carb
#> Mazda RX4 16.46 0 1 4 4
#> Mazda RX4 Wag 17.02 0 1 4 4
#> Datsun 710 18.61 1 1 4 1
#> Hornet 4 Drive 19.44 1 0 3 1
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.