RenderPlotly filter the X-axis date into range

Good day everyone, may I know how to filter out the x-axis data into a range?

This is what I get.

and I want it to be like this.

Below is my code
image

I would guess your dates aren't in a date type but are character strings representing dates. You should fix that first.

Also its a bad idea to share code text as an image when you can share it by copy and pasting into the forum posts. The forum posts support a simple markdown so code formatting is available by signifying open and close of a code block with triple backticks

```
share code like this
```

But my dates are in date type already. :sweat_smile:

what is the output of str(datatable$Date) please ?

Is a date. Example : 2020-02-15

consider this example (by running this code and seeing the results)


notreallyadate <-'2020-02-15'
arealdate <- as.Date('2020-02-15')

str(notreallyadate)
str(arealdate)

output$lineChart <- renderPlotly({
datatable$Date <- as.Date(datatable$Date)

p <- ggplot(data=datatable, aes(x= Date, y= `Total Cases`, group=1))+
  geom_line(color = 'lightyellow')+
  geom_point()+
  scale_x_date(labels = date_format("%m-%Y"))+
  ylab("Total Cases")+
  xlab("Date")


p<- ggplotly(p)
p

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.