数组(不同的日期、值)、箱线图:x - 日期,y - 值

Array (different dates, values), boxplots: x - dates, y - values

我是 R 的新手。我有这样的数据:

Date;Value

2019-01-31;125

2019-01-31;127

2019-01-31;120

2019-01-31;116

2019-01-31;119

...

2019-02-01;222

2019-02-01;233

2019-02-01;225

2019-02-01;222

2019-02-01;222

...


2019-02-02;111

2019-02-02;234

2019-02-02;876

2019-02-02;234

2019-02-02;983

...

现在我有两个月的数据,但还会有更多。一天 = 288 条记录。

我想创建类似这样的箱线图 https://imgur.com/a/kO1iSPA 其中 V12 = date1v11 = date2、...

图片来源:

我已经阅读了上面的主题,但是我有一个不同的数组。你能帮帮我吗?

如果您有数据框,可以使用库 ggplot2 和函数 geom_boxplot() 为每个日期创建一个箱线图。

df <- data.frame(
  Date  = c(rep('2019-01-31', 50), rep('2019-02-01', 50)),
  Value = round(rnorm(100, 150, 50))
)

library(ggplot2)
library(dplyr)

df %>% 
  ggplot(aes(x = Date, y = Value)) + 
  geom_boxplot()