Objects of various FLCore classes can be converted into other classes,
both basic R ones, like data.frame
, and others defined in the package. For
the specifics of the precise calculations carried out for each pair of
classes, see below.
FLArray to data.frame
The six dimensions of an FLArray
are converted into seven columns, named
quant
(or any other name given to the first dimension in the object),
year
, unit
, season
, area
, iter
and data
. The last one contains
the actual numbers stored in the array. units
are stored as an attribute
to the data.frame
. The year
and data
columns are of type numeric
,
while all others are factor
.
FLPar to data.frame
The two or more dimensions of an FLPar objects are converted into three or
more columns. For a 2D objects, they are named params, iter and data.
The last one contains the actual numbers stored in the array, in a column
type numeric
, while all others are factor
.
Examples
# from FLQuant to data.frame
as(FLQuant(rnorm(100), dim=c(5, 20)), "data.frame")
#> quant year unit season area iter data
#> 1 1 1 unique all unique 1 1.78763033
#> 2 2 1 unique all unique 1 1.29512026
#> 3 3 1 unique all unique 1 1.34458461
#> 4 4 1 unique all unique 1 -0.50866954
#> 5 5 1 unique all unique 1 -1.12067009
#> 6 1 2 unique all unique 1 2.15080494
#> 7 2 2 unique all unique 1 -0.56171975
#> 8 3 2 unique all unique 1 -1.31150938
#> 9 4 2 unique all unique 1 0.28638227
#> 10 5 2 unique all unique 1 0.48502761
#> 11 1 3 unique all unique 1 -0.71824346
#> 12 2 3 unique all unique 1 0.16284173
#> 13 3 3 unique all unique 1 0.10048785
#> 14 4 3 unique all unique 1 0.37686006
#> 15 5 3 unique all unique 1 0.22373575
#> 16 1 4 unique all unique 1 1.51603757
#> 17 2 4 unique all unique 1 1.26931582
#> 18 3 4 unique all unique 1 -0.13913783
#> 19 4 4 unique all unique 1 0.60704860
#> 20 5 4 unique all unique 1 -0.25928567
#> 21 1 5 unique all unique 1 -0.59147634
#> 22 2 5 unique all unique 1 -0.94550205
#> 23 3 5 unique all unique 1 0.23658792
#> 24 4 5 unique all unique 1 -0.09734917
#> 25 5 5 unique all unique 1 2.04488154
#> 26 1 6 unique all unique 1 1.20847318
#> 27 2 6 unique all unique 1 -1.83053363
#> 28 3 6 unique all unique 1 0.64945194
#> 29 4 6 unique all unique 1 1.00227863
#> 30 5 6 unique all unique 1 -1.35915129
#> 31 1 7 unique all unique 1 0.19702464
#> 32 2 7 unique all unique 1 -2.15306430
#> 33 3 7 unique all unique 1 -1.77982626
#> 34 4 7 unique all unique 1 -1.25637544
#> 35 5 7 unique all unique 1 1.28399957
#> 36 1 8 unique all unique 1 0.70016193
#> 37 2 8 unique all unique 1 0.41712779
#> 38 3 8 unique all unique 1 -0.09821147
#> 39 4 8 unique all unique 1 1.23387018
#> 40 5 8 unique all unique 1 0.38769108
#> 41 1 9 unique all unique 1 -0.16425606
#> 42 2 9 unique all unique 1 -0.41694062
#> 43 3 9 unique all unique 1 -0.01955970
#> 44 4 9 unique all unique 1 -1.28679411
#> 45 5 9 unique all unique 1 -1.06172725
#> 46 1 10 unique all unique 1 -0.65346943
#> 47 2 10 unique all unique 1 0.54605449
#> 48 3 10 unique all unique 1 -0.55388324
#> 49 4 10 unique all unique 1 1.08120000
#> 50 5 10 unique all unique 1 0.61657147
#> 51 1 11 unique all unique 1 0.10733408
#> 52 2 11 unique all unique 1 -0.00991494
#> 53 3 11 unique all unique 1 -0.77790812
#> 54 4 11 unique all unique 1 1.16752702
#> 55 5 11 unique all unique 1 0.43972735
#> 56 1 12 unique all unique 1 -0.79019806
#> 57 2 12 unique all unique 1 -1.23396101
#> 58 3 12 unique all unique 1 0.43384015
#> 59 4 12 unique all unique 1 0.28184582
#> 60 5 12 unique all unique 1 -1.73771157
#> 61 1 13 unique all unique 1 -0.85059636
#> 62 2 13 unique all unique 1 1.86252316
#> 63 3 13 unique all unique 1 1.23862928
#> 64 4 13 unique all unique 1 -0.59566744
#> 65 5 13 unique all unique 1 0.91076876
#> 66 1 14 unique all unique 1 -0.26576998
#> 67 2 14 unique all unique 1 0.31774589
#> 68 3 14 unique all unique 1 0.37823141
#> 69 4 14 unique all unique 1 -0.90150371
#> 70 5 14 unique all unique 1 1.21432212
#> 71 1 15 unique all unique 1 -0.22544166
#> 72 2 15 unique all unique 1 -0.21746329
#> 73 3 15 unique all unique 1 1.04560399
#> 74 4 15 unique all unique 1 1.79337756
#> 75 5 15 unique all unique 1 -0.10441185
#> 76 1 16 unique all unique 1 0.78948099
#> 77 2 16 unique all unique 1 -2.07292184
#> 78 3 16 unique all unique 1 2.21463109
#> 79 4 16 unique all unique 1 1.57844773
#> 80 5 16 unique all unique 1 1.22404338
#> 81 1 17 unique all unique 1 -0.04916270
#> 82 2 17 unique all unique 1 0.34662763
#> 83 3 17 unique all unique 1 2.19509878
#> 84 4 17 unique all unique 1 0.57898798
#> 85 5 17 unique all unique 1 -0.69747658
#> 86 1 18 unique all unique 1 0.44808265
#> 87 2 18 unique all unique 1 0.33083346
#> 88 3 18 unique all unique 1 -0.99741189
#> 89 4 18 unique all unique 1 -0.14125862
#> 90 5 18 unique all unique 1 -0.90833732
#> 91 1 19 unique all unique 1 0.55064754
#> 92 2 19 unique all unique 1 -0.80809562
#> 93 3 19 unique all unique 1 -1.83893557
#> 94 4 19 unique all unique 1 0.90553241
#> 95 5 19 unique all unique 1 -1.45875228
#> 96 1 20 unique all unique 1 -0.80164698
#> 97 2 20 unique all unique 1 -0.91078482
#> 98 3 20 unique all unique 1 -1.40536731
#> 99 4 20 unique all unique 1 2.19468463
#> 100 5 20 unique all unique 1 -1.13869430
# from FLPar to data.frame
as(FLPar(phi=rnorm(10), rho=rlnorm(10)), "data.frame")
#> params iter data
#> 1 phi 1 0.1822600
#> 2 rho 1 3.6417114
#> 3 phi 2 -0.3206102
#> 4 rho 2 1.0118828
#> 5 phi 3 0.4063791
#> 6 rho 3 1.9171083
#> 7 phi 4 -0.6228697
#> 8 rho 4 0.3915606
#> 9 phi 5 -0.7322529
#> 10 rho 5 0.7894674
#> 11 phi 6 0.2540571
#> 12 rho 6 0.1592711
#> 13 phi 7 0.1513072
#> 14 rho 7 1.2529434
#> 15 phi 8 -0.4464694
#> 16 rho 8 1.0286380
#> 17 phi 9 0.2632531
#> 18 rho 9 2.6425528
#> 19 phi 10 1.7090840
#> 20 rho 10 0.8634691