Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k views
in Technique[技术] by (71.8m points)

r markdown - Advanced `data.table` working fine when run in chunk but error when `knit2html`

I tried to refer to below links to use data.table package to calculate mape,smape,mse,rmse, its working fine with below codes when run in chunk but become error when knit2html. Somebody shade me a light?

## https://tysonbarrett.com/jekyll/update/2019/10/06/datatable_memory
## http://brooksandrew.github.io/simpleblog/articles/advanced-data-table
require('DescTools')
require('data.table')

setorder(seasonal_m1, index)

open.accr <- seasonal_m1[, {
  open = open
  open.Point.Forecast = open.Point.Forecast
  .SD[, .(.N, open.mape = MAPE(open, open.Point.Forecast), 
          open.smape = SMAPE(open, open.Point.Forecast), 
          open.mse = MSE(open, open.Point.Forecast), 
          open.rmse = RMSE(open, open.Point.Forecast)), 
      by={index=as_date(index)}]}, 
  by=.(Model, Period)]

Error :

Error in `[.tbl_df`(seasonal_m1, , { : 
  object 'open.Point.Forecast' not found
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> [ -> [.tbl_df
Execution halted

error knit2html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
seasonal_m1 <- data.table(seasonal_m1)
setorder(seasonal_m1, index) 

solved, need to convert seasonal_m1 to a data.table format. https://github.com/yihui/knitr/issues/1941#issuecomment-759275616


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...