rforecastets# How to forecast continuous in R

I'm novice in R and im doing a forecast for my dataset, as you can see in the diagram, the data before 2019,04 is training data, the part in blue (start from 2019,04- 2019,12) is my forecast and the red line is the test data(2019,04- 2019,12), the time interval is identical, but in the diagram it isn't continuous, how can I fix it?

```
library(forecast)
fit_ets %>% forecast(h=9) %>%
autoplot()+
autolayer(testing)
```

Solution

if by continuous you mean that the black line is not "connected" to the red nor the blue: each line has a first and last observation which are connected via lines (and have possibly more observations).

Your first value to predict (or test) is, chronologically speaking, after the training data, thus the black line will not reach the blue and red. Also the blue and red line can not reach back to connect as the last observation from training data is not included in theire data.

After forecasting you could include the last observation from the training data in test and prediction set. This will lead to a "continuous" line when plotting.

- Check values of column 1 present in values of column 2
- Scraping specific elements from various websites and saving them in the same vector
- Custom replacement matrix for edit distance in R
- How to remove duplicate rows in R?
- Add a common ylab to patchwork plots in r
- lm(): What is qraux returned by QR decomposition in LINPACK / LAPACK
- Heatmap of matrix with 2 variables in upper and lower triangles using R ggplot2
- ggplot2: creating double bar plot with one column representing x and y
- Identify connected subnetworks, constrained by edge attributes
- how to display factor in scientific notation
- Map one column's distinct values to the count of those values in a chart
- Simple Function in R error
- Using quotation marks in an R function
- calculating percentage change in a for loop
- How can I count and return which strings in a list have been detected using str_detect?
- create new columns based on the column names in tidyverse
- Trying to Differentiate lines in a Rain Cloud Plot
- Debugging generic functions in R
- Why does my plot utilizing geom_density not reach the x-axis?
- Multinomial Logistic regression in R studio
- ggplot2 & ggpattern: How to specify legend columns/rows when fill and pattern are cobined?
- Geographic / geospatial distance between 2 lists of lat/lon points (coordinates)
- Count frequency based on multiple columns
- Dynamic Scaling of geom_tile in ggplot2
- How to plot a secondary axis in facets with ggplot?
- geom_area stacks areas by default
- reduce the gap between left-aligned (hjust=0) and right-aligned (hjust=1) in axis label in ggplot2
- How to Keep scales free with limiting scale_y_sqrt in ggplot2?
- running a PCA on a RasterStack in R
- How can I extract a value from a dataframe based on a range of values?