Skip to contents

Read and transform LabChart's HRV report file (.txt) to a tidy tibble with one row per file.

Usage

read_HRV_reports(file, format_cols = TRUE, encoding = "UTF-16LE", ...)

Arguments

file

(Character) Path to LabChart's HRV report (.txt) files to be read. Path can point to an individual text file (.txt) or a folder which contains those files.

format_cols

(Logical) If TRUE formats appropriate output variables as factor, integer, or double, and compute NN50_percent (pNN50) from NN50_count/Normals_count

encoding

(Character) Text encoding of the HRV report files. Default value is set to "UTF-16LE" as it works well with my testing data. If the result seems abnormal, try different text encoding (visit readtext manual to see all available options)

...

extra arguments passed to readtext::readtext()

Value

A tibble of HRV report (one row per subject)

Details

read_HRV_reports() reads contents of LabChart's HRV report from text file (.txt) into character vector using readtext::readtext() function with default text encoding as "UTF-16LE". Then, each key-value fields of the character vector will be extracted and transform into a tibble by regular expression pattern matching as in parse_HRV_reports().

The result will be a tibble with column names corresponding to "key" in the input file(s), and values in each rows mapped to "value" from the input file(s).

Examples

# Path to `HRV/` folder containing example HRV report files (`.txt`)
path <- labChartHRV_example("HRV")
# Read into tibble
read_HRV_reports(path)
#> # A tibble: 4 × 41
#>   doc_id    File_LabChart Channel   Date  Start_time End_time Name  Gender   Age
#>   <chr>     <chr>         <fct>     <chr> <chr>      <chr>    <chr> <fct>  <int>
#> 1 file1.txt file1         Channel 2 16/2… 16/2/2563… 16/2/25… John  Male      60
#> 2 file2.txt file2         Channel 2 26/3… 26/3/2563… 26/3/25… Max   Male      56
#> 3 file3.txt file3         Channel 2 19/8… 19/8/2563… 19/8/25… Mary  Female    65
#> 4 file4.txt file4         Channel 2 10/9… 19/10/256… 19/10/2… Tom   Female    63
#> # … with 32 more variables: Beats_tot <dbl>, Rec_length <dbl>,
#> #   Class_bound <chr>, Discontinuities <dbl>, Beats_inserted <dbl>,
#> #   Beats_deleted <dbl>, NN_max <dbl>, NN_min <dbl>, NN_range <dbl>,
#> #   NN_mean <dbl>, NN_median <dbl>, HR_avg <dbl>, SDNN <dbl>, SD_del_NN <dbl>,
#> #   RMSSD <dbl>, Normals_count <dbl>, Ectopics_count <dbl>,
#> #   Artifacts_count <dbl>, NN50_count <dbl>, NN50_percent <dbl>,
#> #   Spec_intv <dbl>, Spec_mean_NN <dbl>, Power_tot <dbl>, VLF_freq <chr>, …