I am trying to create a line plot, using two different variables to specify colors and shapes respectively. But I get no plot and an error message in return, which I do not understand.

Preparing data frame

df <- expand.grid(x = 1:4, type = c("a", "b"), category = c("this", "that"), stringsAsFactors = FALSE)
df$val <- rnorm(nrow(df), mean = 5)
df$grp <- with(df, paste0(type, " ", category))

Attempt to plot with shape and color specified:

ggpubr::ggline(data = df, x = "x", y = "val", group = "grp", shape = "type", color = "category")

Output:

Error in `purrr::pmap()`:
i In index: 1.
i With name: val.
Caused by error in `purrr::map()`:
i In index: 2.
i With name: group.
Caused by error in `if (is_parsable_aes(x)) ...`:
! the condition has length > 1

Khám phá các thẻ bài đăng