Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)

I am having the following data for a grouped lollipop chart:

grp     percent   percent_min   perc_max

Cold       82.3          81.5   83.5

Warm       84.4          82.2   86.3

For the chart, I have implemented the following code:

  dataframe %>%

  ggplot(aes(grp, percent)) + 

  geom_linerange(aes(x = grp, 

                     ymin = 75, 

                     ymax = percent), 

                 position = position_dodge(width = 1)) +

  geom_point(size = 7, 

             position = position_dodge(width = 1)) 

I just wanted to ask that how can I get one error bar for "cold" and another error bar for "warm?"

1 Answer

0 votes
by (108k points)

For achieving that, just refer to the following code:

library(tidyverse)

dataframe %>%

  ggplot(aes(grp, percent)) + 

  geom_linerange(aes(x = grp, 

                     ymin = 75, 

                     ymax = percent), 

                 position = position_dodge(width = 1)) +

  geom_point(size = 7, position = position_dodge(width = 1)) +

  geom_errorbar(aes(ymin = percent_min, ymax = perc_max))

If you are a beginner and want to know more about R then do check out the R programming course.

Browse Categories

...