Skip to contents

Shift the values and add a shadow column. It also respects the dplyr verbs starts_with, contains, ends_with, etc.

Usage

cast_shadow_shift(data, ...)

Arguments

data

data.frame

...

One or more unquoted variable names separated by commas. These respect the dplyr verbs starts_with, contains, ends_with, etc.

Value

data.frame with the shadow and shadow_shift vars

Examples


airquality %>% cast_shadow_shift(Ozone,Temp)
#> # A tibble: 153 × 6
#>    Ozone  Temp Ozone_NA Temp_NA Ozone_shift Temp_shift
#>    <int> <int> <fct>    <fct>         <dbl>      <int>
#>  1    41    67 !NA      !NA            41           67
#>  2    36    72 !NA      !NA            36           72
#>  3    12    74 !NA      !NA            12           74
#>  4    18    62 !NA      !NA            18           62
#>  5    NA    56 NA       !NA           -19.7         56
#>  6    28    66 !NA      !NA            28           66
#>  7    23    65 !NA      !NA            23           65
#>  8    19    59 !NA      !NA            19           59
#>  9     8    61 !NA      !NA             8           61
#> 10    NA    69 NA       !NA           -18.5         69
#> # ℹ 143 more rows

airquality %>% cast_shadow_shift(dplyr::contains("o"))
#> # A tibble: 153 × 12
#>    Ozone Solar.R Month Ozone_NA Solar.R_NA Month_NA Ozone_shift Solar.R_shift
#>    <int>   <int> <int> <fct>    <fct>      <fct>          <dbl>         <dbl>
#>  1    41     190     5 !NA      !NA        !NA             41           190  
#>  2    36     118     5 !NA      !NA        !NA             36           118  
#>  3    12     149     5 !NA      !NA        !NA             12           149  
#>  4    18     313     5 !NA      !NA        !NA             18           313  
#>  5    NA      NA     5 NA       NA         !NA            -19.7         -33.6
#>  6    28      NA     5 !NA      NA         !NA             28           -33.1
#>  7    23     299     5 !NA      !NA        !NA             23           299  
#>  8    19      99     5 !NA      !NA        !NA             19            99  
#>  9     8      19     5 !NA      !NA        !NA              8            19  
#> 10    NA     194     5 NA       !NA        !NA            -18.5         194  
#> # ℹ 143 more rows
#> # ℹ 4 more variables: Month_shift <int>, Ozone_NA_shift <fct>,
#> #   Solar.R_NA_shift <fct>, Month_NA_shift <fct>