Session Ready
Exercise

Subsetting with .SD

When building processing pipelines, you want the ability to adapt your pipeline to the data flowing through it without making code changes. For example, imagine that you want to do something like extract a particular subset of columns from a sensor dataset. This can be done with .SDcols!

Throughout the exercises in this chapter, a data.table called diagnosticDT will be pre-loaded for you. You can inspect it by running head(diagnosticDT) in the console.

This course touches on a lot of concepts you may have forgotten, so if you ever need a quick refresher, download the data.table Cheat Sheet and keep it handy!

Instructions 1/4
undefined XP
  • 1
    • Create voltageDT, a data.table containing timestamp and system_voltage, using .() subsetting.
    • 2
      • Create voltageDT, a data.table containing "timestamp" and "system_voltage", using .SD subsetting.
    • 3
      • Create voltageDT, a dataset with "timestamp" and "system_voltage", using .SD and the voltage_cols vector.
    • 4
      • Print a data.table with the value of "system_voltage" and its timestamp at the most recent observation in diagnosticDT.