R 中数据透视 table 的特定版本(无聚合)

specific version of pivot table in R (without aggregation)

我们取 data.frame:

df <- data.frame(
  name = c(rep('John',5), rep('Mike',5), rep('Julia',5)),
  date = rep(c(Sys.Date()+c(1:5)),3),
  text = c(LETTERS[1:15])
)

我想要table喜欢下面的图片

如果列文本是整数 (dcast),我知道该怎么做,但对于字符我无能为力

tidyverse 版本

library(tidyr)
df %>% pivot_wider(names_from = date, values_from = text)
df %>%
  mutate(date = format(date, '%d.%m.%Y')) %>%
  pivot_wider(names_from = date, values_from = text)
#> # A tibble: 3 x 6
#>   name  `13.04.2021` `14.04.2021` `15.04.2021` `16.04.2021` `17.04.2021`
#>   <chr> <chr>        <chr>        <chr>        <chr>        <chr>       
#> 1 John  A            B            C            D            E           
#> 2 Mike  F            G            H            I            J           
#> 3 Julia K            L            M            N            O