[英]Is there a way to use facet_grid with interactive plot_ly in R?
[英]How to use sjplot in R function plot_grpfrq in a "facet grid" way based on another variable
我的數據框中有三個變量。 A、B 和 C。我對 C 給定 A 和 B 組合的相對頻率感興趣。
我的數據集使用 dput:
structure(list(B = structure(c(1L, 1L, 3L, 3L, 3L, 2L), .Label = c("text1",
"text2", "text3"), class = "factor"), A = structure(c(3L,
4L, 4L, 2L, 2L, 3L), .Label = c("Control_base", "Control_info",
"TreatA", "TreatB"), class = "factor"), , C = structure(c(1,
0, 2, 3, 2, 3), format.stata = "%9.0g", labels = c(somea = 0,
someb = 1, somec = 2, somed = 3), class = c("haven_labelled", "vctrs_vctr",
"double"))), row.names = c(NA, -6L), class = c("tbl_df", "tbl",
"data.frame"))
我想使用 sjplot plot_grpfrq 但是,我想要 4 個圖(用於我的四個 B 類)。 但是此代碼不起作用:
data %>% group_by(B) %>%
plot_grpfrq(
var.cnt = data$A,
var.grp = data$C) %>%
plot_grid()
報錯:Error in match.arg(type): 'arg' must be NULL or a character vector
此代碼有效:
plot_grpfrq(
var.cnt = data$A,
var.grp = data$C)
這些代碼也有效:
data %>% group_by(B) %>%
plot_frq(C) %>%
plot_grid()
和
data %>% group_by(A) %>%
plot_frq(C) %>%
plot_grid()
我在這里缺少什么嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.