0

I need to predict the number of flights for 2019 per day. I already have a model to but I need to apply it for the 2019 data. So I may need to add a column contains the date for 2019 to the original data set.

I tried to create_series(), but it can't be mutated to the original data set.

Error in mutate_impl(.data, dots) : Column "date_2019" is of unsupported class data.frame

f2019 <- create_series(~'2019', 'daily')
flight2019 <- daily %>%
  mutate(date(f2019))

I also tried data$,

daily$date2019 <- create_series(~'2019', 'daily')

but the value is not normal.

date2019
<S3: tbl_time>
<S3: tbl_time>
<S3: tbl_time>
<S3: tbl_time>
<S3: tbl_time>
<S3: tbl_time>
<S3: tbl_time>

I think the problem is in create_series(), maybe I should use other function to create date variable. I except the daily has a column contains each date in 2019. i.e,

2019-01-01
2019-01-02
...

or replace the date of daily with 2019's date. (Original date is 2013 in daily)

the data set is following:

# A tibble: 365 x 13
   date           n wday  term  residual_wday1 wday2 wday3
   <date>     <int> <ord> <fct>          <dbl> <chr> <chr>
 1 2013-01-01   842 Tue   wint~        -56.3   Tue   Tue  
 2 2013-01-02   943 Wed   wint~         25.7   Wed   Wed  
 3 2013-01-03   914 Thu   wint~        -23.7   Thu   Thu  
 4 2013-01-04   915 Fri   wint~        -17.2   Fri   Fri  
 5 2013-01-05   720 Sat   wint~         18.6   Sat-~ Sat-~
 6 2013-01-06   832 Sun   wint~          2     Sun   Sun  
 7 2013-01-07   933 Mon   wint~         -0.25  Mon   Mon  
 8 2013-01-08   899 Tue   wint~          0.667 Tue   Tue  
 9 2013-01-09   902 Wed   wint~        -15.3   Wed   Wed  
10 2013-01-10   932 Thu   wint~         -5.67  Thu   Thu  
# ... with 355 more rows, and 6 more variables:
dayucpbx7
  • 15
  • 3
  • Welcome to Stack Overflow! Your question is precise, but in order for us to understand and solve it, it is necessary that you provide some sample data. There are several ways to provide data, probably adding the output of `dput()` or `dput(head())` to your question is sufficient. Avoid adding code or alphanumeric output as images. Consider how to make a good example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and see how you can change your question accordingly. – heck1 Mar 28 '19 at 06:53
  • Thank you so much! It's my first time to use stack overflow! I will pay attention to this in the future. – dayucpbx7 Mar 28 '19 at 07:02
  • OK, I add it in the post. – dayucpbx7 Mar 28 '19 at 07:16
  • please try adding the contents of `dput(head())` to your question. – heck1 Mar 28 '19 at 07:19
  • I edited it, is that OK? – dayucpbx7 Mar 28 '19 at 07:21
  • No, it's not the contents of `dput(head())` , is it? – heck1 Mar 28 '19 at 07:28
  • Ok, I looked over your code again: try: `daily$date2019 <- f2019$date` ? – heck1 Mar 28 '19 at 07:30
  • What is `create_series()`? – Igor F. Mar 28 '19 at 07:44
  • It works! Really appreciate! – dayucpbx7 Mar 28 '19 at 07:50

1 Answers1

0

have you seen this post: How to create a range of dates in R

and function: seq(as.Date("2014/09/04"), by = "day", length.out = 5)

then you can just add new rows with function rbind()