Issues with nested table using purrr package--converted TS objects have datatype character instead of dbl #806
-
Hi all, Hoping someone with experience with nested table to help me out. I have nested table with 45 rows, and I would like to convert train data to time series objects ts and msts for fitting. So that has been done with no issue, however I notice that the params list contains character type S3:ts objects, which is out of the ordinary because the previous times I have done this the datatype is usually dbl. As a result I'm unable to fit the models, because of this non-numeric TS objects. I tried a workaround to use lapply for all elements inside the list to convert them to numeric, but when this is done its no longer a time series object. Hoping someone can help! Thank you
The above code runs fine and are as expected with the exception of the class of the params list, which is character instead of dbl like usual. I have explicitly coerce the target variable as numeric but somehow the resulting TS object becomes character. I believe this is the cause of the problem as the other times when the type of params is 'dbl' there has been no issues. Please note that the following code results in error:
Error in
Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Dear @princessblackswan , Pertanyaan Anda sudah kami baca dan sedang kami telusuri permasalahannya. Harap menunggu untuk balasan selanjutnya, terima kasih banyak. |
Beta Was this translation helpful? Give feedback.
-
It seems like the issue might be arising from the structure of the To resolve this, you can modify the code to ensure that the walmart_improve_nested <- walmart_improve_nested %>%
mutate(params = map(train, ts_function$ts_obj))
# Continue with the rest of your code
walmart_improve_nested <- walmart_improve_nested %>%
mutate(
data = invoke_map(ts_func, params),
params = map(data, ~list(x = .x))
)
... This modification directly applies |
Beta Was this translation helpful? Give feedback.
-
Halo @princessblackswan , karena tidak ada konfirmasi lebih lanjut dan untuk menjaga agar forum diskusi tetap berjalan kondusif, kami izin melakukan lock/close diskusi ini. Semoga dapat dipahami. |
Beta Was this translation helpful? Give feedback.
It seems like the issue might be arising from the structure of the
params
list. Specifically, when you apply theinvoke_map
function tomodel_func
andparams
, it might not be handling the character type of your time series objects correctly.To resolve this, you can modify the code to ensure that the
params
list contains numeric time series objects. You can do this by directly applying your time series functions (ts_obj
andmsts_obj
) to the data within thetrain
list. Here's a modified version of your code: