Re: [R] Add a new row based on test set predicted values and time stamps

2021-04-13 Thread Jeff Newmiller
The date you get using as.Date on a POSIXct value depends on the timezone. That is, as.Date only pays attention to the underlying UTC seconds-since-epoch value, so it ignores the timezone which can be unexpected for most people. TL;DR as.Date is not the same as as.POSIXct( trunc( dtm, units="da

Re: [R] Add a new row based on test set predicted values and time stamps

2021-04-13 Thread Bert Gunter
(Revealing my ignorance): Simpler still than the as.POSIXct() idiom is just to use the as.Date version: out <- with(out, out [order(Group, id, as.Date(Date)),]) ## all else the same... Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into i

Re: [R] Add a new row based on test set predicted values and time stamps

2021-04-13 Thread Bert Gunter
It may not be necessary to insert the rows in that order -- R can identify and use the information from the rows in in most cases without it. So to combine the results as you described (the code you sent got garbled a bit btw -- you should proofread more carefully in future), all you would need to

[R] Add a new row based on test set predicted values and time stamps

2021-04-13 Thread Elahe chalabi via R-help
Hi all, I have the prediction for my test set which are forecasted Value for "4/1/2020" for each match of "id" and "Group". I would like to add a fourth row to each group by (Group,id) in my train set and the values for this row should come from test set : my train set:       structure(list(D