data.table tips

Updated: 2021-09-17 Some tips for data.table that I came across while googling which might be useful. Print To print more rows that default can be done with either: options(datatable.print.topn = 70) print(DT, topn = 70) Using options will implement the changes globally.

Read More

Ellipsis …

Updated: 2022-10-09 Just to remind me how I could use ellipsis or the three dots ... in my coding. There are three scenarios I find it useful: Function wrapper When creating a function wrapper and instead of providing all the arguments to be send further, you could just use .

Read More

Case when

It’s often easier to use ifelse to implement conditioning. The fast implementation in data.table of ifelse is fifelse. Other approach to do multiple conditioning is to use data.table::fcase or dplyr::case_when. fcase fcase can be used directly x <- 1:6 data.table::fcase(x < 3, 1, x >= 4, 2) To implement in a data.

Read More

Connect to MS Access DB

DBI RODBC R6 Class Debug DBI Connection Updated 15.09.2022 Before connecting to your Access DBMS via Windows OS, you can check if you have the MS Access driver installed in your machine by running ## List everything odbc::odbcListDrivers() ## You will get the results someting like this.

Read More

Basic use of drake

There are various ways to organise your R workflow. If you are working with a big project, then Airflow might be for you. But for the majority of R project codes, drake package will fullfilled your need. Here is the basic use of drake.

Read More