Last active
September 28, 2017 12:24
-
-
Save lvalnegri/82c5e4797542132c9ba0df084fc8bba7 to your computer and use it in GitHub Desktop.
any trick, or trivial way to do thing that I easily tend to forget, about most used R packages
cols2del <- c('v1', 'v2', 'v3')
dt[, (cols2del) := NULL]
- sum all columns
dt[, lapply(.SD, sum, na.rm = TRUE), .SDcols = names(dt)]
- sum all columns except the id:
dt[, lapply(.SD, sum, na.rm = TRUE), .SDcols = setdiff(names(dt), 'id')]
- only one column:
dt[, sum(is.na(var))]
- some columns:
dt[, sum(is.na(var))]
- all table:
dt[, sum(is.na(var))]
dt[order(V1, V2)][, .SD[1], id]
dt[order(V1, V2)][, .SD[.N], id]
There are different methods:
dt[, head(.SD, n), grp]
dt[, .SD[1:n], grp]
dt[dt[, .I[1:n], grp]$V1]
this is the fastest, despite being a bit weird to write down
display.brewer.all()
-
Sequential
Suited to ordered data that progress from low to high. Lightness steps dominate the look of these schemes, with light colors for low data values to dark colors for high data values. -
Qualitative
Qualitative schemes are best suited to representing nominal or categorical data.do not imply magnitude differences between legend classes, and hues are used to create the primary visual differences between classes. -
Diverging
Put equal emphasis on mid-range critical values and extremes at both ends of the data range. The critical class or break in the middle of the legend is emphasized with light colors and low and high extremes are emphasized with dark colors that have contrasting hues.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment