I tried using the code as per your suggestion, but I see somewhere there is a discrepancy in the chart. When I plotted the same in Excel, it was a smooth line trending up, but when I used my code, the ggplot plotted lines that were up and downs, whereas the data didn't show any lowering of the values. I am sending you the actual code and link to the raw data too. Please let me know why there is a difference in both excel and ggplot graphs.
library(ggplot2)
library(tidyverse)
library(dplyr)
C.US <- read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_US.csv", col_types = cols())
USC_ts <- C.US %>%
select (States = "Province_State", "Admin2", starts_with ("Comb"), ends_with("20"))
USC_ts <- data.table(USC_ts)
USC_ts <- USC_ts[,Combined_Key :=NULL] #deleting the column Combined_Key
USC_ts <- USC_ts %>% group_by(States) %>%
summarize_if(is.numeric, sum)
USC_tsgg <- pivot_longer(USC_ts, cols = 2:142, names_to = "Date", values_to = "Value")
USC_tsgg <- USC_tsgg %>% mutate(Value = Value/100)
USC_tsgg <- USC_tsgg %>% select(States,Date,Value)
USC_tsgg<- as.data.frame(USC_tsgg)
ggplot(USC_tsgg, aes(x = Date, y = Value, group = States, color= States)) + geom_line()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5))
Also is there anyway, I could instead of showing all dates in x-axis, just display like week dates, or start date, mid month date, and end month date, because when I display all dates, the chart is clumsy.