Open franknarf1 opened 7 years ago
Possible typos in existing examples:
library(package = "_your_new_package_")
, should be help(package = "_your_new_package_")
?Misc additions
Re basics, just link to Q&A re loop traps https://stackoverflow.com/q/52597296 though really it applies beyond R, with any mutable objects
Re sets (under "getting work done"), anyDuplicated ("Read the docs, use it with big table x, note the speedup vs any(duplicated(x))")
Similarly, re missing values (under "basics"), anyNA
In Basics > Vectors, the gl() function for making fancy sequences (I'm also thinking about use of grouping() which seems to supply data.table internals...)
shift
ing a single column by group where fill= is a constant can be addressed by sorting on grouping vars and using ungrouped shift. Also applies to x - shift(x, fill=first(x)) or x > shift(x, fill=first(x)), since those are 0 & FALSE by construction https://github.com/Rdatatable/data.table/issues/1534 (just saved myself from a long computation by searching the issues for this...)
(looking at those i contributed to Docs.SO...)
Cleaning data
DT = data.table(id = c(1,2,2,3,3,3))[, v := LETTERS[.I]][]
... going beyond Docs.SO:
Creating a data.table
A data.table is an enhanced version of the data.frame class from base R. As such, its
class()
attribute is the vector"data.table" "data.frame"
and functions that work on a data.frame will also work with a data.table. There are many ways to create, load or coerce to a data.table, as seen here.Adding and modifying columns
... hm, this is getting somewhat tedious. i will dump the contents into a new file,
exercises.something
Another: https://stackoverflow.com/q/49282735/