【发布时间】:2020-07-26 12:03:25
【问题描述】:
我想从 reshape2 包中的 acast 函数创建一个表。
我在这里提供了示例,我需要“手动”创建结果,我需要知道 R 中是否有这样做的函数。
library(tidyverse)
library(reshape2)
mtcars %>%
head(6) %>%
add_rownames(var = "Names") %>%
acast(Names ~ gear)
# What I want to create is
tibble(
`3` = c("Hornet 4 Drive", "Hornet Sportabout", "Valiant"),
`4` = c("Datsun 710", "Mazda RX4", "Mazda RX4 Wag"))
【问题讨论】: