Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add examples/exercises #12

Open
franknarf1 opened this issue Aug 3, 2017 · 1 comment
Open

add examples/exercises #12

franknarf1 opened this issue Aug 3, 2017 · 1 comment

Comments

@franknarf1
Copy link
Owner

franknarf1 commented Aug 3, 2017

(looking at those i contributed to Docs.SO...)

Cleaning data

... 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.

  • modify data.frame by reference
  • rbindlist a bunch of sub-tables built with data.table()
  • coerce a data.frame
  • copy()
  • fread()

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/

@franknarf1
Copy link
Owner Author

franknarf1 commented Jul 27, 2018

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...)

  • shifting 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 shift() in data.table v1.9.6 is slow for many groups Rdatatable/data.table#1534 (just saved myself from a long computation by searching the issues for this...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant