This function is used by the package, and can also be called by the user who wishes to study problematic lines in a file in a standalone manner. See the examples.
decompLines(VL, debug = 0)
Character. The variable list to be processed as a character vector.
Depending upon the mode
and the stage of processing:
the lines may be named as "Line_1" etc
a format code may be present as the first entry
there may be other non-numeric lines that eventually get stripped off
Integer. See readJDX
for details.
A list of numeric strings, the result of unpacking the compressed data. One list element is returned for each line. The numeric string is named with the ASDF compression mode.
Each individual line passed here is converted to a list to make processing and naming the pieces easier.The individual entries are named according to their original ASDF compression code. Unless otherwise noted all functions called from here should act on a list of lines, via lapply. Note too that the X values are present, e.g. X, Y1, Y2 ... Yn.
AFFN is separated by any amount of white space so processing is straightforward, as exponents are handled automatically, and white space stripped off automatically, courtesy of R internals. It appears AFFN is never mixed with other formats. The other formats are collectively called ASDF in the standard.
testLines1 <- c(
"482A885145L989378k853295J46714q39581j382088R41076k774051J365135l135709P53917",
"472a903359j71857q18832K573831k615133L481852l395846L894844l478693M916433",
"463B483240m513444O146172m826168N233079m522551M000252m097028L466111l460183",
"454i0520L061628k524598K788931k509430L219286k511160K709095k122775J594246"
)
demo1 <- decompLines(testLines1, debug = 6)
#>
#>
#>
#> ==================== Raw lines:
#>
#> [1] "482A885145L989378k853295J46714q39581j382088R41076k774051J365135l135709P53917"
#> [2] "472a903359j71857q18832K573831k615133L481852l395846L894844l478693M916433"
#> [3] "463B483240m513444O146172m826168N233079m522551M000252m097028L466111l460183"
#> [4] "454i0520L061628k524598K788931k509430L219286k511160K709095k122775J594246"
#>
#>
#>
#> ==================== Lines after preliminary processing:
#>
#> $Line_1
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> "482" "A885145" "L989378" "k853295" "J46714" "q39581" "j382088" "R41076"
#> DIF DIF DIF DIF
#> "k774051" "J365135" "l135709" "P53917"
#>
#> $Line_2
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> "472" "a903359" "j71857" "q18832" "K573831" "k615133" "L481852" "l395846"
#> DIF DIF DIF
#> "L894844" "l478693" "M916433"
#>
#> $Line_3
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> "463" "B483240" "m513444" "O146172" "m826168" "N233079" "m522551" "M000252"
#> DIF DIF DIF
#> "m097028" "L466111" "l460183"
#>
#> $Line_4
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> "454" "i0520" "L061628" "k524598" "K788931" "k509430" "L219286" "k511160"
#> DIF DIF DIF
#> "K709095" "k122775" "J594246"
#>
#>
#> Undoing DIF compression:
#>
#> Line_1 passed to deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> "482" "1885145" "L989378" "k853295" "J46714" "q39581" "j382088" "R41076"
#> DIF DIF DIF DIF
#> "k774051" "J365135" "l135709" "P53917"
#>
#> Line_1 as processed by deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> 482 1885145 5874523 3021228 3167942 2328361 946273 1887349
#> DIF DIF DIF DIF
#> -886702 478433 -2657276 -1903359
#>
#> Undoing DIF compression:
#>
#> Line_2 passed to deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF
#> "472" "-1903359" "j71857" "q18832" "K573831" "k615133" "L481852"
#> DIF DIF DIF DIF
#> "l395846" "L894844" "l478693" "M916433"
#>
#> Line_2 as processed by deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> 472 -1903359 -2075216 -2894048 -320217 -2935350 546502 -2849344
#> DIF DIF DIF
#> 1045500 -2433193 2483240
#>
#> Undoing DIF compression:
#>
#> Line_3 passed to deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> "463" "2483240" "m513444" "O146172" "m826168" "N233079" "m522551" "M000252"
#> DIF DIF DIF
#> "m097028" "L466111" "l460183"
#>
#> Line_3 as processed by deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> 463 2483240 -2030204 4115968 -710200 4522879 328 4000580
#> DIF DIF DIF
#> -96448 3369663 -90520
#>
#> Undoing DIF compression:
#>
#> Line_4 passed to deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF DIF
#> "454" "-90520" "L061628" "k524598" "K788931" "k509430" "L219286" "k511160"
#> DIF DIF DIF
#> "K709095" "k122775" "J594246"
#>
#> Line_4 as processed by deDIF:
#> NUM SQZ DIF DIF DIF DIF DIF DIF DIF DIF
#> 454 -90520 2971108 446510 3235441 726011 3945297 1434137 4143232 2020457
#> DIF
#> 3614703
#>
#> Carrying out Y value checks...
#>
#> yValueCheck sees a literal DIF mode on Line_1
#> yValueCheck is removing the last value, -1903359 from Line_1
#>
#> yValueCheck sees a literal DIF mode on Line_2
#> yValueCheck is removing the last value, 2483240 from Line_2
#>
#> yValueCheck sees a literal DIF mode on Line_3
#> yValueCheck is removing the last value, -90520 from Line_3
#>
#>
#> yValueCheck: Line_4 does not appear to be a checkpoint line
#>
#>
#> ...Y value checks completed
#>
#>
#>
#> ==================== Lines after full processing to numeric:
#>
#> $Line_1
#> [1] 482 1885145 5874523 3021228 3167942 2328361 946273 1887349
#> [9] -886702 478433 -2657276
#>
#> $Line_2
#> [1] 472 -1903359 -2075216 -2894048 -320217 -2935350 546502 -2849344
#> [9] 1045500 -2433193
#>
#> $Line_3
#> [1] 463 2483240 -2030204 4115968 -710200 4522879 328 4000580
#> [9] -96448 3369663 -90520
#>
#> $Line_4
#> [1] 454 2971108 446510 3235441 726011 3945297 1434137 4143232 2020457
#> [10] 3614703
#>
testLines2 <- c(
# EU AFFN:
"1898,58486802541 -0,0170190036296844 -0,0170874372124672 -0,0171865783631802",
"1917,23501403401 -0,0176097713410854 -0,0177919361740351 -0,0179808251559734",
# AFFN with fixed field width/extra space:
" 16383 2259260 -5242968 -7176216 -1616072",
" 16379 10650432 4373926 -3660824 2136488"
)
demo2 <- decompLines(testLines2, debug = 6)
#>
#>
#>
#> ==================== Raw lines:
#>
#> [1] "1898,58486802541 -0,0170190036296844 -0,0170874372124672 -0,0171865783631802"
#> [2] "1917,23501403401 -0,0176097713410854 -0,0177919361740351 -0,0179808251559734"
#> [3] " 16383 2259260 -5242968 -7176216 -1616072"
#> [4] " 16379 10650432 4373926 -3660824 2136488"
#>
#>
#>
#> ==================== Lines after preliminary processing:
#>
#> $Line_1
#> NUM NUM NUM
#> "1898.58486802541" "-0.0170190036296844" "-0.0170874372124672"
#> NUM
#> "-0.0171865783631802"
#>
#> $Line_2
#> NUM NUM NUM
#> "1917.23501403401" "-0.0176097713410854" "-0.0177919361740351"
#> NUM
#> "-0.0179808251559734"
#>
#> $Line_3
#> NUM NUM NUM NUM NUM
#> "16383" "2259260" "-5242968" "-7176216" "-1616072"
#>
#> $Line_4
#> NUM NUM NUM NUM NUM
#> "16379" "10650432" "4373926" "-3660824" "2136488"
#>
#>
#>
#>
#> ==================== Lines after full processing to numeric:
#>
#> $Line_1
#> [1] 1898.58486803 -0.01701900 -0.01708744 -0.01718658
#>
#> $Line_2
#> [1] 1917.23501403 -0.01760977 -0.01779194 -0.01798083
#>
#> $Line_3
#> [1] 16383 2259260 -5242968 -7176216 -1616072
#>
#> $Line_4
#> [1] 16379 10650432 4373926 -3660824 2136488
#>