Extract Model Description from a mable

亡梦爱人 提交于 2020-08-11 05:13:15

问题


I have a mable object that is like so:

models
# A mable: 1 x 3
  ets           arima                     nnetar             
  <model>       <model>                   <model>            
1 <ETS(M,Ad,M)> <ARIMA(2,1,2)(0,0,2)[12]> <NNAR(14,1,10)[12]>

I just want the models descriptions so I can place them in a plot. So I ran the following code:

model_desc <- models %>% 
  gather() %>% 
  select(key, value) %>% 
  set_names("model","model_desc") %>%
  mutate(model_desc_char = model_desc %>% as.character())
  as_tibble() %>%
  select(model, model_desc)

This still gives me back a tibble where model_desc is still a list object. I think this is because of how a mable is constructed and how its structure is supposed to be.

** UPDATE ** I solved the problem by doing the following:

model_desc <- models %>% 
  as_tibble() %>%
  gather() %>%
  mutate(model_desc = print(value)) %>%
  select(key, model_desc) %>%
  set_names("model", "model_desc")

回答1:


This ended up solving my issue:

model_desc <- models %>% 
  as_tibble() %>%
  gather() %>%
  mutate(model_desc = print(value)) %>%
  select(key, model_desc) %>%
  set_names("model", "model_desc")


来源:https://stackoverflow.com/questions/59721759/extract-model-description-from-a-mable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!