We at STATWORX work a lot with R and we often use the same little helper functions within our projects. These functions ease our daily work life by reducing repetitive code parts or by creating overviews of our projects. At first, there was no plan to make a package, but soon I realised, that it will be much easier to share and improve those functions, if they are within a package. Up till the 24th December I will present one function each day from
helfRlein. So, on the 13th day of Christmas my true love gave to me…
What can it do?
This little helper reads in multiple files of the same type and combines them into a
data.table. What kind of „file reading function“ should be used can be choosen by the
How to use it?
If you have a list of files, that all needs to be loaded in with the same function (e.g.
read.csv), instead of using
rbindlist now you can use this:
read_files(files, FUN = readRDS) read_files(files, FUN = readLines) read_files(files, FUN = read.csv, sep = ";")
Internally, it just uses
rbindlist but you dont have to type it all the time. The
read_files combines the single files by their column names and returns one data.table. Why data.table? Because I like it. But, let's not go down the rabbit hole of data.table vs dplyr (to the rabbit hole …).
Have a merry advent season!