shadow_shift transforms missing values to facilitate visualisation, and has different behaviour for different types of variables. For numeric variables, the values are shifted to 10% below the minimum value for a given variable plus some jittered noise, to separate repeated values, so that missing values can be visualised along with the rest of the data.

shadow_shift(x, ...)

Arguments

x

a variable of interest to shift

...

extra arguments to pass

See also

Examples

airquality$Ozone
#> [1] 41 36 12 18 NA 28 23 19 8 NA 7 16 11 14 18 14 34 6 #> [19] 30 11 1 11 4 32 NA NA NA 23 45 115 37 NA NA NA NA NA #> [37] NA 29 NA 71 39 NA NA 23 NA NA 21 37 20 12 13 NA NA NA #> [55] NA NA NA NA NA NA NA 135 49 32 NA 64 40 77 97 97 85 NA #> [73] 10 27 NA 7 48 35 61 79 63 16 NA NA 80 108 20 52 82 50 #> [91] 64 59 39 9 16 78 35 66 122 89 110 NA NA 44 28 65 NA 22 #> [109] 59 23 31 44 21 9 NA 45 168 73 NA 76 118 84 85 96 78 73 #> [127] 91 47 32 20 23 21 24 44 21 28 9 13 46 18 13 24 16 13 #> [145] 23 36 7 14 30 NA 14 18 20
shadow_shift(airquality$Ozone)
#> [1] 41.00000 36.00000 12.00000 18.00000 -19.72321 28.00000 23.00000 #> [8] 19.00000 8.00000 -18.51277 7.00000 16.00000 11.00000 14.00000 #> [15] 18.00000 14.00000 34.00000 6.00000 30.00000 11.00000 1.00000 #> [22] 11.00000 4.00000 32.00000 -17.81863 -19.43853 -15.14310 23.00000 #> [29] 45.00000 115.00000 37.00000 -16.17315 -14.65883 -17.85609 -13.29299 #> [36] -16.16323 -19.60935 29.00000 -19.65780 71.00000 39.00000 -13.40961 #> [43] -13.53728 23.00000 -19.65993 -16.48342 21.00000 37.00000 20.00000 #> [50] 12.00000 13.00000 -17.17718 -16.74073 -13.65786 -16.78786 -12.30098 #> [57] -13.33171 -16.77414 -17.08225 -15.98818 -19.17558 135.00000 49.00000 #> [64] 32.00000 -14.27138 64.00000 40.00000 77.00000 97.00000 97.00000 #> [71] 85.00000 -13.51764 10.00000 27.00000 -13.48998 7.00000 48.00000 #> [78] 35.00000 61.00000 79.00000 63.00000 16.00000 -16.92150 -16.60335 #> [85] 80.00000 108.00000 20.00000 52.00000 82.00000 50.00000 64.00000 #> [92] 59.00000 39.00000 9.00000 16.00000 78.00000 35.00000 66.00000 #> [99] 122.00000 89.00000 110.00000 -14.78907 -16.19151 44.00000 28.00000 #> [106] 65.00000 -19.73591 22.00000 59.00000 23.00000 31.00000 44.00000 #> [113] 21.00000 9.00000 -18.92235 45.00000 168.00000 73.00000 -14.86296 #> [120] 76.00000 118.00000 84.00000 85.00000 96.00000 78.00000 73.00000 #> [127] 91.00000 47.00000 32.00000 20.00000 23.00000 21.00000 24.00000 #> [134] 44.00000 21.00000 28.00000 9.00000 13.00000 46.00000 18.00000 #> [141] 13.00000 24.00000 16.00000 13.00000 23.00000 36.00000 7.00000 #> [148] 14.00000 30.00000 -14.83089 14.00000 18.00000 20.00000
if (FALSE) { library(dplyr) airquality %>% mutate(Ozone_shift = shadow_shift(Ozone)) }