为什么日期不能正确显示在 X 轴上?
Why can't the date correctly be displayed on the X-axis?
代码
library(shiny)
library(ggplot2)
library(reshape2)
library(plotly)
data <- read.csv("https://covid.ourworldindata.org/data/full_data.csv")
data$date <- as.Date(data$date, format = "%Y-%m-%d")
class(data$date)
data$location <- as.character(data$location)
ggplot(data = data, mapping = aes(x = date, y = total_cases, color = location)) +
geom_line()
我建议您搜索 scale_x_date
并使用它来自定义日期标签。
代码
library(shiny)
library(ggplot2)
library(reshape2)
library(plotly)
data <- read.csv("https://covid.ourworldindata.org/data/full_data.csv")
data$date <- as.Date(data$date, format = "%Y-%m-%d")
class(data$date)
data$location <- as.character(data$location)
ggplot(data = data, mapping = aes(x = date, y = total_cases, color = location)) +
geom_line()
我建议您搜索 scale_x_date
并使用它来自定义日期标签。