Install

Typically one installs using install_github from the package devtools with the following code:

library(devtools)
install_github('jkennel/rbr')

One can also install from a source file where you choose the appropriate tar.gz file.

install.packages(file.choose(), repos = NULL, type = 'source')

Load package

library(rbr)

Read data from rsk file

This reads a single file.

file_name_and_path <- '/media/kennel/Data/phd/personnel/pat/syngenta/SYN UW1 Baro P1 - 077653_20150410_1435.rsk'
file_name_and_path <- '../../../Downloads/GDC-07 BARO 077654_20190208_1209.rsk'
rbr_data <- read_rbr(db_name = file_name_and_path, use_rbr_tz = FALSE)
nrow(rbr_data)

Read data from rsk file and filter by date

This reads in a single file and filters it by date.

rbr_data <- filter_rbr( db_name = file_name_and_path, 
                      start_date = '2014-12-20', 
                      end_date = '2014-12-21', 
                      use_rbr_tz = FALSE)
nrow(rbr_data)

Read all files in folder

This reads in all files from a folder.

folder_path <- '/media/kennel/Data/phd/personnel/pat/syngenta'
rbr_data <- read_rbr_folder(folder_path, use_rbr_tz = FALSE)
nrow(rbr_data)

Read all files in folder and filter by date

This reads in all files from a folder.

rbr_data <- filter_rbr_folder(folder_path, 
                      start_date = '2014-12-20', 
                      end_date = '2014-12-21',
                      use_rbr_tz = FALSE)
nrow(rbr_data)

Read a set of files given a vector of file names and paths.

# get the first three file names and paths from the folder
(files <- list.files(folder_path, full.names = TRUE, pattern = '*.rsk')[1:3])

rbr_data <- read_rbr_files(files, use_rbr_tz = FALSE)
nrow(rbr_data)

Read a set of files given a vector of file names and paths and filters by date.

rbr_data <- filter_rbr_files(files, 
                      start_date = '2014-12-20', 
                      end_date = '2014-12-21', 
                      use_rbr_tz = FALSE)

nrow(rbr_data)

List .rsk info

info <- rbr_info(file_name_and_path)
(info)

List tables in .rsk

db <- DBI::dbConnect(RSQLite::SQLite(),file_name_and_path)

nm_tbl <- DBI::dbListTables(db)

(nm_tbl)

List fields for each table in .rsk

lapply(nm_tbl, function(x) dplyr::tbl(db,x))


jkennel/rbr documentation built on Feb. 15, 2023, 1:37 a.m.