Skip to contents

To extract score variables from QR_matrix or mQR_matrix objects.

Usage

extract_score(
  x,
  format_output = c("data.frame", "vector"),
  weighted_score = FALSE
)

Arguments

x

a QR_matrix or mQR_matrix.

format_output

string of characters indicating the output format: either a data.frame or a vector.

weighted_score

logical indicating whether to extract the weighted score (if previously calculated) or the unweighted one. By default, the unweighted score is extracted.

Value

extract_score() returns a data.frame with two column: the series name and their score.

Details

For QR_matrix objects, the output is a vector or the object NULL if no score was previously calculated. For mQR_matrix objects, it is a list of scores (NULL elements or vectors).

Examples

# Path of matrix demetra_m
demetra_path <- file.path(
    system.file("extdata", package = "JDCruncheR"),
    "WS/ws_ipi/Output/SAProcessing-1",
    "demetra_m.csv"
)

# Extract the quality report from the demetra_m file
QR <- extract_QR(demetra_path)

# Compute the score
QR1 <- compute_score(x = QR, n_contrib_score = 5)
QR2 <- compute_score(
    x = QR,
    score_pond = c(qs_residual_sa_on_sa = 5, qs_residual_sa_on_i = 30,
                   f_residual_td_on_sa = 10, f_residual_td_on_i = 40,
                   oos_mean = 30, residuals_skewness = 15, m7 = 25)
)
mQR <- mQR_matrix(list(a = QR1, b = QR2))

# Extract score
extract_score(QR1)
#>    series score
#> 1  RF0610   140
#> 2  RF0620   105
#> 3  RF0811   280
#> 4  RF0812   245
#> 5  RF0893    75
#> 6  RF0899   240
#> 7  RF1011   460
#> 8  RF1012   505
#> 9  RF1013   460
#> 10 RF1020   515
#> 11 RF1031   300
#> 12 RF1032   305
#> 13 RF1039   510
extract_score(mQR)
#> $a
#>    series score
#> 1  RF0610   140
#> 2  RF0620   105
#> 3  RF0811   280
#> 4  RF0812   245
#> 5  RF0893    75
#> 6  RF0899   240
#> 7  RF1011   460
#> 8  RF1012   505
#> 9  RF1013   460
#> 10 RF1020   515
#> 11 RF1031   300
#> 12 RF1032   305
#> 13 RF1039   510
#> 
#> $b
#>    series score
#> 1  RF0610    70
#> 2  RF0620   135
#> 3  RF0811   205
#> 4  RF0812   200
#> 5  RF0893    90
#> 6  RF0899   240
#> 7  RF1011   340
#> 8  RF1012   430
#> 9  RF1013   455
#> 10 RF1020   430
#> 11 RF1031   200
#> 12 RF1032   290
#> 13 RF1039   445
#>