Skip to contents

La fonction set_value_ts modifie la ou les valeurs d'un objet ts à une date donnée.

Usage

set_value_ts(series, date_ts, replacement)

Arguments

series

un objet ts unidimensionnel conforme aux règles de assert_ts

date_ts

un vecteur numérique, de préférence integer au format AAAA, c(AAAA, MM) ou c(AAAA, TT)

replacement

un vecteur de même type que le ts series

Value

En sortie, la fonction retourne une copie de l'objet series modifié avec les valeurs de replacement imputés à partir de la date date_ts.

Examples

set_value_ts(
    series = ev_pib,
    date_ts = c(2021L, 2L),
    replacement = c(1, 2, 3)
)
#>               Qtr1          Qtr2          Qtr3          Qtr4
#> 1970            NA            NA            NA            NA
#> 1971            NA            NA            NA            NA
#> 1972            NA            NA            NA            NA
#> 1973            NA            NA            NA            NA
#> 1974            NA            NA            NA            NA
#> 1975            NA            NA            NA            NA
#> 1976            NA            NA            NA            NA
#> 1977            NA            NA            NA            NA
#> 1978            NA            NA            NA            NA
#> 1979            NA            NA            NA            NA
#> 1980            NA  -0.552712174  -0.086754850  -0.130764175
#> 1981   0.436797694   0.663555818   0.655755678   0.465977515
#> 1982   0.892058545   0.662204954   0.047370440   0.507157219
#> 1983   0.581233329  -0.042548981   0.077874681   0.583935348
#> 1984   0.619554314   0.363253711   0.462243113   0.288218891
#> 1985   0.123719710   0.631349292   0.756575266   0.327524429
#> 1986   0.357772133   1.122129272   0.326669036   0.370966439
#> 1987   0.251659155   1.144598588   0.680758053   1.694026185
#> 1988   1.231391234   0.593185145   1.302640709   1.065361026
#> 1989   1.260037978   0.825806743   1.075064005   1.523944130
#> 1990   0.517826385   0.377746880   0.459923112   0.366254003
#> 1991  -0.156699858   0.309591699   0.289346425   0.496079715
#> 1992   0.967856839  -0.057920191   0.028450027  -0.223321860
#> 1993  -0.556650909   0.039547303   0.133452547   0.269728893
#> 1994   0.725093411   1.095551160   0.539244435   0.886607198
#> 1995   0.569503181   0.478767111   0.081524147   0.164939274
#> 1996   0.631394447   0.165893251   0.621382576   0.125750143
#> 1997   0.302664793   1.148738446   0.785645124   1.092788520
#> 1998   0.838700519   0.933602781   0.685747514   0.764421531
#> 1999   0.504428016   0.825984551   1.222733930   1.401265205
#> 2000   0.909693692   0.987402187   0.624501289   0.812645817
#> 2001   0.547797973   0.184046964   0.272336544   0.026816438
#> 2002   0.372541324   0.461330701   0.418587141  -0.054011578
#> 2003   0.203235664  -0.218262571   0.676991816   0.717703853
#> 2004   0.939180093   0.645697044   0.258638250   0.744155119
#> 2005   0.269714193   0.198490900   0.500009124   0.776948575
#> 2006   0.754542470   1.015941519   0.013572258   0.786297420
#> 2007   0.740940215   0.773456477   0.351755993   0.225637214
#> 2008   0.395791727  -0.412315400  -0.280602493  -1.467532567
#> 2009  -1.632375943  -0.101454578   0.160750061   0.695136221
#> 2010   0.368232308   0.507493101   0.645610703   0.704301595
#> 2011   0.997901680   0.027941934   0.367134262   0.173618343
#> 2012   0.093557392  -0.157293866   0.191962538  -0.077204189
#> 2013  -0.001133455   0.655711072   0.012011561   0.475525630
#> 2014   0.084980333   0.118498226   0.504372721   0.081229345
#> 2015   0.489945372   0.007744848   0.332080732   0.139118865
#> 2016   0.636268205  -0.161024723   0.198728721   0.544690904
#> 2017   0.816780164   0.820053915   0.622880698   0.828202860
#> 2018   0.048700300   0.382559370   0.366396552   0.701164421
#> 2019   0.665798334   0.604099134   0.011971808  -0.400152537
#> 2020  -5.647477753 -13.443145590  18.555378962  -1.118046566
#> 2021   0.156198162   1.000000000   2.000000000   3.000000000
#> 2022  -0.047254400            NA            NA