Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 当ggplot有多个图层时如何使用镶嵌网格镜_R_Ggplot2 - Fatal编程技术网

R 当ggplot有多个图层时如何使用镶嵌网格镜

R 当ggplot有多个图层时如何使用镶嵌网格镜,r,ggplot2,R,Ggplot2,我正在使用trelliscopejs包中的facet\u网格镜进行数据可视化。当我的ggplot只有一层时,它工作得很好。但如果我引入第二层,它就不能正确地刻面。例如: # Load packages library(tidyverse) library(trelliscopejs) # Basic stat summary table using iris stat_sum <- iris %>% group_by(Species) %>% summar

我正在使用
trelliscopejs
包中的
facet\u网格镜
进行数据可视化。当我的ggplot只有一层时,它工作得很好。但如果我引入第二层,它就不能正确地刻面。例如:

# Load packages
library(tidyverse)
library(trelliscopejs)    

# Basic stat summary table using iris
stat_sum <-
  iris %>%
  group_by(Species) %>%
  summarise(l_mean = mean(Sepal.Length))

#Standard ggplot with facet_wrap 
ggplot(iris, aes(Sepal.Length, Petal.Width)) +
  geom_point() +
  geom_vline(data = stat_sum, aes(xintercept = l_mean)) +
  facet_wrap(~Species) 


我知道我可以操纵一个新的数据框来包含原始数据旁边的统计摘要,但如果可能的话,我不想这样做

多个层可以很好地使用网格镜JS,但在这种特殊情况下,层有自己的数据。已准备好修复程序,以使此案例也能正常工作。

对于需要快速修复的任何人,请参阅:。有一个开发分支可用。
# Use facet_trelliscope. Data from stat_sum does not facet
ggplot(iris, aes(Sepal.Length, Petal.Width)) +
  geom_point() +
  geom_vline(data = stat_sum, aes(xintercept = l_mean)) +
  facet_trelliscope(~Species)