Shadow shift missing values using only the selected variables in a dataset, by specifying variable names or use dplyr vars and dplyr verbs starts_with, contains, ends_with, etc.

add_shadow_shift(data, ..., suffix = "shift")

Arguments

data

data.frame

...

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

suffix

suffix to add to variable, defaults to "shift"

Value

data with the added variable shifted named as var_suffix

See also

Examples

pedestrian %>% add_shadow_shift(hourly_counts)
#> # A tibble: 37,700 x 10 #> hourly_counts date_time year month month_day week_day hour #> <int> <dttm> <int> <ord> <int> <ord> <int> #> 1 883 2016-01-01 00:00:00 2016 Janu… 1 Friday 0 #> 2 597 2016-01-01 01:00:00 2016 Janu… 1 Friday 1 #> 3 294 2016-01-01 02:00:00 2016 Janu… 1 Friday 2 #> 4 183 2016-01-01 03:00:00 2016 Janu… 1 Friday 3 #> 5 118 2016-01-01 04:00:00 2016 Janu… 1 Friday 4 #> 6 68 2016-01-01 05:00:00 2016 Janu… 1 Friday 5 #> 7 47 2016-01-01 06:00:00 2016 Janu… 1 Friday 6 #> 8 52 2016-01-01 07:00:00 2016 Janu… 1 Friday 7 #> 9 120 2016-01-01 08:00:00 2016 Janu… 1 Friday 8 #> 10 333 2016-01-01 09:00:00 2016 Janu… 1 Friday 9 #> # ... with 37,690 more rows, and 3 more variables: sensor_id <int>, #> # sensor_name <chr>, hourly_counts_shift <dbl>
airquality %>% add_shadow_shift(Ozone, Solar.R)
#> # A tibble: 153 x 8 #> Ozone Solar.R Wind Temp Month Day Ozone_shift Solar.R_shift #> <int> <int> <dbl> <int> <int> <int> <dbl> <dbl> #> 1 41 190 7.4 67 5 1 41 190 #> 2 36 118 8 72 5 2 36 118 #> 3 12 149 12.6 74 5 3 12 149 #> 4 18 313 11.5 62 5 4 18 313 #> 5 NA NA 14.3 56 5 5 -19.7 -33.6 #> 6 28 NA 14.9 66 5 6 28 -33.1 #> 7 23 299 8.6 65 5 7 23 299 #> 8 19 99 13.8 59 5 8 19 99 #> 9 8 19 20.1 61 5 9 8 19 #> 10 NA 194 8.6 69 5 10 -18.5 194 #> # ... with 143 more rows