Skip to contents

This function takes the df_new output from regularize_time_series and convert it into another format

Usage

convert_to_wide_format(df_new, id_col = "id", time_col = "time")

Arguments

df_new

a regularized dataframe

id_col

col_name of df_new for the id

time_col

col_name of df_new for the id

Value

the dataframe in wide format

Author

Francois Bassac

Examples

id_df = data.frame(id=rep(1,5), time=seq(0, 40, 10), state=c(0, 1, 1, 0, 1))
id_df_new = regularize_time_series(id_df, time_seq = seq(0, 40, 2), curve_type = 'cat')
convert_to_wide_format(id_df_new)
#> # A tibble: 1 × 22
#>      id   `0`   `2`   `4`   `6`   `8`  `10`  `12`  `14`  `16`  `18`  `20`  `22`
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1     1     0     0     0     0     0     1     1     1     1     1     1     1
#> # ℹ 9 more variables: `24` <dbl>, `26` <dbl>, `28` <dbl>, `30` <dbl>,
#> #   `32` <dbl>, `34` <dbl>, `36` <dbl>, `38` <dbl>, `40` <dbl>