How to add summary statistics in histogram plot using ggplot2?

后端 未结 1 1450
死守一世寂寞
死守一世寂寞 2021-02-10 10:14

I want to add summary statistics in histogram plot made using ggplot2. I am using the following code

#Loading the required packages
library(dplyr)
l         


        
1条回答
  •  囚心锁ツ
    2021-02-10 10:55

    You need to split your data.frame:

    p1+geom_table_npc(data=summ,label =split(summ,summ$variable),
    npcx = 0.00, npcy = 1, hjust = 0, vjust = 1,size=2)
    

    or nest the summary table you have:

    summ <- summ %>% nest(data=-c(variable))
    
    # A tibble: 4 x 2
      variable               data
              >
    1 Sepal.Length        [1 × 9]
    2 Sepal.Width         [1 × 9]
    3 Petal.Length        [1 × 9]
    4 Petal.Width         [1 × 9]
    
    p1+geom_table_npc(data = summ,label =summ$data,
    ,npcx = 0.00, npcy = 1, hjust = 0, vjust = 1)
    

    0 讨论(0)
提交回复
热议问题