Analogous function for select
in dplyr.
select_dt(data, ..., cols = NULL)
data | data.frame |
---|---|
... | List of variables or name-value pairs of summary/modifications functions. |
cols | (Optional)A numeric or character vector. |
data.table
iris %>% select_dt(Species)#> Species #> 1: setosa #> 2: setosa #> 3: setosa #> 4: setosa #> 5: setosa #> --- #> 146: virginica #> 147: virginica #> 148: virginica #> 149: virginica #> 150: virginicairis %>% select_dt(Sepal.Length,Sepal.Width)#> Sepal.Length Sepal.Width #> 1: 5.1 3.5 #> 2: 4.9 3.0 #> 3: 4.7 3.2 #> 4: 4.6 3.1 #> 5: 5.0 3.6 #> --- #> 146: 6.7 3.0 #> 147: 6.3 2.5 #> 148: 6.5 3.0 #> 149: 6.2 3.4 #> 150: 5.9 3.0#> Sepal.Length Sepal.Width #> 1: 5.1 3.5 #> 2: 4.9 3.0 #> 3: 4.7 3.2 #> 4: 4.6 3.1 #> 5: 5.0 3.6 #> --- #> 146: 6.7 3.0 #> 147: 6.3 2.5 #> 148: 6.5 3.0 #> 149: 6.2 3.4 #> 150: 5.9 3.0iris %>% select_dt(1:3)#> Sepal.Length Sepal.Width Petal.Length #> 1: 5.1 3.5 1.4 #> 2: 4.9 3.0 1.4 #> 3: 4.7 3.2 1.3 #> 4: 4.6 3.1 1.5 #> 5: 5.0 3.6 1.4 #> --- #> 146: 6.7 3.0 5.2 #> 147: 6.3 2.5 5.0 #> 148: 6.5 3.0 5.2 #> 149: 6.2 3.4 5.4 #> 150: 5.9 3.0 5.1iris %>% select_dt(1,3)#> Sepal.Length Petal.Length #> 1: 5.1 1.4 #> 2: 4.9 1.4 #> 3: 4.7 1.3 #> 4: 4.6 1.5 #> 5: 5.0 1.4 #> --- #> 146: 6.7 5.2 #> 147: 6.3 5.0 #> 148: 6.5 5.2 #> 149: 6.2 5.4 #> 150: 5.9 5.1iris %>% select_dt("Pe")#> Petal.Length Petal.Width #> 1: 1.4 0.2 #> 2: 1.4 0.2 #> 3: 1.3 0.2 #> 4: 1.5 0.2 #> 5: 1.4 0.2 #> --- #> 146: 5.2 2.3 #> 147: 5.0 1.9 #> 148: 5.2 2.0 #> 149: 5.4 2.3 #> 150: 5.1 1.8iris %>% select_dt("Pe|Sp")#> Petal.Length Petal.Width Species #> 1: 1.4 0.2 setosa #> 2: 1.4 0.2 setosa #> 3: 1.3 0.2 setosa #> 4: 1.5 0.2 setosa #> 5: 1.4 0.2 setosa #> --- #> 146: 5.2 2.3 virginica #> 147: 5.0 1.9 virginica #> 148: 5.2 2.0 virginica #> 149: 5.4 2.3 virginica #> 150: 5.1 1.8 virginicairis %>% select_dt(cols = 2:3)#> Sepal.Width Petal.Length #> 1: 3.5 1.4 #> 2: 3.0 1.4 #> 3: 3.2 1.3 #> 4: 3.1 1.5 #> 5: 3.6 1.4 #> --- #> 146: 3.0 5.2 #> 147: 2.5 5.0 #> 148: 3.0 5.2 #> 149: 3.4 5.4 #> 150: 3.0 5.1#> Sepal.Width Petal.Length #> 1: 3.5 1.4 #> 2: 3.0 1.4 #> 3: 3.2 1.3 #> 4: 3.1 1.5 #> 5: 3.6 1.4 #> --- #> 146: 3.0 5.2 #> 147: 2.5 5.0 #> 148: 3.0 5.2 #> 149: 3.4 5.4 #> 150: 3.0 5.1