Skip to contents

Parse and transform LabChart's HRV report from a character vector to a tidy tibble

Usage

parse_HRV_reports(x, format_cols = TRUE)

Arguments

x

(Character) Character vectors of HRV report, each elements corresponding to one report.

format_cols

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

Value

A tibble of HRV report (one row per subject)

Details

parse_HRV_reports() extracts key and value pairs from each fields of LabChart's HRV report supplied as character vectors using regular expression for pattern matching. Extracted data then transform into a tibble with "key" mapping to column names and "value" mapping to corresponding cells. If x is given as character vector of length > 1, there will be multiple rows of tibble with each rows corresponding to each input character vectors.

See also

read_HRV_reports(): read LabChart's HRV report from file(s) path.

Examples

# Read HRV report to a character vector. Using any reading engine as you like.
hrv_chr <- readtext::readtext(labChartHRV_example("HRV/file1.txt"),
                              encoding = "UTF-16LE")$text
# Parse into a tibble
parse_HRV_reports(hrv_chr)
#> # A tibble: 1 × 40
#>   File_LabChart Channel   Date  Start_time End_time Name  Gender   Age Beats_tot
#>   <chr>         <fct>     <chr> <chr>      <chr>    <chr> <fct>  <int>     <dbl>
#> 1 file1         Channel 2 16/2… 16/2/2563… 16/2/25… John  Male      60       485
#> # … with 31 more variables: 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>, VLF <dbl>, LF_freq <chr>, LF <dbl>, …