0

I have a project where I have error = "error in seq.int(0, to0 - from, by) : 'to' must be a finite number" Here is the code. Can y'all help?

library(ggplot2)
library(dplyr)
library(plyr)
library(tidyverse)
library(DataExplorer)
library(ggrepel)

raw_data = mutate(raw_data, Date.Announced= as.Date(Date.Announced, format="%d/%m/%y"))
raw_data = raw_data[order(as.numeric(raw_data$Date.Announced)),]

daily_rate = raw_data[,c("Date.Announced" , "Patient.Number")]
count_daily = count(daily_rate,"Date.Announced")
count_daily

ggplot(count_daily, aes(x=Date.Announced, y=freq)) +
  geom_segment( aes(x=Date.Announced, xend=Date.Announced, y=0, yend=freq),
                color="red") +
  geom_point( color="orange", size=1) +
  theme_light() +
  scale_x_date(date_breaks = "1 week",date_labels = "%d %b")+
  theme(
    panel.grid.major.x = element_blank(),
    panel.border = element_blank(),
    axis.ticks.x = element_blank()
  ) +
  xlab("") +
  labs(title = "Daily Increase in the Number of Patients")+
  ylab("Number of patients")

I know it is an error related to date format but I have no idea as to how to solve it.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
  • 1
    (a) Can you share a little bit of sample data so we can reproduce the problem? Using `dput()` is a nice way to share copy/pasteable sample data with all structure and class info included. (b) Can you indicate which line of code causes the error? (c) Loading `plyr` after `dplyr` is a terrible idea and can cause problems - it prints a big warning when you do this. I don't think it has anything to do with this particular problem, but don't use `plyr` at all if you can avoid it. If you do need both `plyr` and `dplyr`, make sure to use `library(plyr)` **before** `library(dplyr)`. – Gregor Thomas May 13 '21 at 13:49
  • Yeah I can share, tell me how to – Jash Rana May 13 '21 at 13:58
  • @GregorThomas already gave good instructions, but there is an extensive description here: https://stackoverflow.com/a/5963610/5805670. – slamballais May 13 '21 at 14:03

0 Answers0