`dplyr::full_join()` 不适用于列表列
`dplyr::full_join()` doesn't work with list columns
我正在尝试比较 R 包 ggstatsplot
中给定函数的两个版本的形式化。我已经能够在 tibbles 中提取形式,但我似乎无法让这两个表加入。 dplyr::full_join()
会产生一个错误,但并不清楚它的含义。非常感谢有关如何加入这两个数据框的任何反馈。
# setup
set.seed(123)
library(tidyverse)
library(ggstatsplot)
# formals for the primary version of the function
(df_primary <- tibble::enframe(formals(ggstatsplot::gghistostats)) %>%
dplyr::rename(.data = ., primary = value))
#> # A tibble: 41 x 2
#> name primary
#> <chr> <list>
#> 1 data <NULL>
#> 2 x <missing>
#> 3 binwidth <NULL>
#> 4 bar.measure <chr [1]>
#> 5 xlab <NULL>
#> 6 title <NULL>
#> 7 subtitle <NULL>
#> 8 caption <NULL>
#> 9 type <chr [1]>
#> 10 test.value <dbl [1]>
#> # ... with 31 more rows
# formals for the grouped version of the function
(df_grouped <- tibble::enframe(formals(ggstatsplot::grouped_gghistostats)) %>%
dplyr::rename(.data = ., grouped = value))
#> # A tibble: 43 x 2
#> name grouped
#> <chr> <list>
#> 1 data <missing>
#> 2 x <missing>
#> 3 grouping.var <missing>
#> 4 title.prefix <NULL>
#> 5 binwidth <NULL>
#> 6 bar.measure <chr [1]>
#> 7 xlab <NULL>
#> 8 subtitle <NULL>
#> 9 caption <NULL>
#> 10 type <chr [1]>
#> # ... with 33 more rows
# joining the two dataframes name
dplyr::full_join(
x = df_primary,
y = df_grouped,
by = "name"
)
#> Error: type not supported
traceback()
#> 4: stop(list(message = "type not supported", call = NULL, cppstack = NULL))
#> 3: full_join_impl(x, y, by_x, by_y, aux_x, aux_y, na_matches, environment())
#> 2: full_join.tbl_df(x = tibble::enframe(formals(ggstatsplot::gghistostats)) %>%
#> dplyr::rename(.data = ., primary = value), y = tibble::enframe(formals(ggstatsplot::grouped_gghistostats)) %>%
#> dplyr::rename(.data = ., grouped = value), by = "name")
#> 1: dplyr::full_join(x = tibble::enframe(formals(ggstatsplot::gghistostats)) %>%
#> dplyr::rename(.data = ., primary = value), y = tibble::enframe(formals(ggstatsplot::grouped_gghistostats)) %>%
#> dplyr::rename(.data = ., grouped = value), by = "name")
由 reprex package (v0.2.1)
于 2019-01-25 创建
似乎不支持 dotted paired
类型。一件事,我们可以将其转换为正常的 list
然后执行 full_join
formals(ggstatsplot::gghistostats) %>%
as.list %>%
tibble::enframe(value = 'primary') %>%
full_join(formals(ggstatsplot::grouped_gghistostats) %>%
as.list %>%
tibble::enframe(value = 'grouped'))
# A tibble: 40 x 3
# name primary grouped
# <chr> <list> <list>
# 1 data <NULL> <missing>
# 2 x <missing> <missing>
# 3 binwidth <NULL> <NULL>
# 4 bar.measure <chr [1]> <chr [1]>
# 5 xlab <NULL> <NULL>
# 6 title <NULL> <NULL>
# 7 subtitle <NULL> <NULL>
# 8 caption <NULL> <NULL>
# 9 type <chr [1]> <chr [1]>
#10 test.value <dbl [1]> <dbl [1]>
# … with 30 more rows
我正在尝试比较 R 包 ggstatsplot
中给定函数的两个版本的形式化。我已经能够在 tibbles 中提取形式,但我似乎无法让这两个表加入。 dplyr::full_join()
会产生一个错误,但并不清楚它的含义。非常感谢有关如何加入这两个数据框的任何反馈。
# setup
set.seed(123)
library(tidyverse)
library(ggstatsplot)
# formals for the primary version of the function
(df_primary <- tibble::enframe(formals(ggstatsplot::gghistostats)) %>%
dplyr::rename(.data = ., primary = value))
#> # A tibble: 41 x 2
#> name primary
#> <chr> <list>
#> 1 data <NULL>
#> 2 x <missing>
#> 3 binwidth <NULL>
#> 4 bar.measure <chr [1]>
#> 5 xlab <NULL>
#> 6 title <NULL>
#> 7 subtitle <NULL>
#> 8 caption <NULL>
#> 9 type <chr [1]>
#> 10 test.value <dbl [1]>
#> # ... with 31 more rows
# formals for the grouped version of the function
(df_grouped <- tibble::enframe(formals(ggstatsplot::grouped_gghistostats)) %>%
dplyr::rename(.data = ., grouped = value))
#> # A tibble: 43 x 2
#> name grouped
#> <chr> <list>
#> 1 data <missing>
#> 2 x <missing>
#> 3 grouping.var <missing>
#> 4 title.prefix <NULL>
#> 5 binwidth <NULL>
#> 6 bar.measure <chr [1]>
#> 7 xlab <NULL>
#> 8 subtitle <NULL>
#> 9 caption <NULL>
#> 10 type <chr [1]>
#> # ... with 33 more rows
# joining the two dataframes name
dplyr::full_join(
x = df_primary,
y = df_grouped,
by = "name"
)
#> Error: type not supported
traceback()
#> 4: stop(list(message = "type not supported", call = NULL, cppstack = NULL))
#> 3: full_join_impl(x, y, by_x, by_y, aux_x, aux_y, na_matches, environment())
#> 2: full_join.tbl_df(x = tibble::enframe(formals(ggstatsplot::gghistostats)) %>%
#> dplyr::rename(.data = ., primary = value), y = tibble::enframe(formals(ggstatsplot::grouped_gghistostats)) %>%
#> dplyr::rename(.data = ., grouped = value), by = "name")
#> 1: dplyr::full_join(x = tibble::enframe(formals(ggstatsplot::gghistostats)) %>%
#> dplyr::rename(.data = ., primary = value), y = tibble::enframe(formals(ggstatsplot::grouped_gghistostats)) %>%
#> dplyr::rename(.data = ., grouped = value), by = "name")
由 reprex package (v0.2.1)
于 2019-01-25 创建似乎不支持 dotted paired
类型。一件事,我们可以将其转换为正常的 list
然后执行 full_join
formals(ggstatsplot::gghistostats) %>%
as.list %>%
tibble::enframe(value = 'primary') %>%
full_join(formals(ggstatsplot::grouped_gghistostats) %>%
as.list %>%
tibble::enframe(value = 'grouped'))
# A tibble: 40 x 3
# name primary grouped
# <chr> <list> <list>
# 1 data <NULL> <missing>
# 2 x <missing> <missing>
# 3 binwidth <NULL> <NULL>
# 4 bar.measure <chr [1]> <chr [1]>
# 5 xlab <NULL> <NULL>
# 6 title <NULL> <NULL>
# 7 subtitle <NULL> <NULL>
# 8 caption <NULL> <NULL>
# 9 type <chr [1]> <chr [1]>
#10 test.value <dbl [1]> <dbl [1]>
# … with 30 more rows