Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:51:18+00:00 2026-06-17T09:51:18+00:00

I just updated my ggplot2 package and I started getting following warning messages with

  • 0

I just updated my ggplot2 package and I started getting following warning messages with my bar chart:

Mapping a variable to y and also using stat=”bin”. With stat=”bin”, it
will attempt to set the y value to the count of cases in each group.
This can result in unexpected behavior and will not be allowed in a
future version of ggplot2. If you want y to represent counts of cases,
use stat=”bin” and don’t map a variable to y. If you want y to
represent values in the data, use stat=”identity”.

I added stat=’identity’ to my code. Now order in stacked bar chart is wrong (order is defined by factor levels). I don’t really know how to resolve it. I can just leave it for now – but warning message says it will not be allowed in future, so I would like to resolve it now. Is there any work around this?

This is data and code example:

data.set <- structure(list(Date = structure(c(15675, 15676, 15677, 15678, 
15679, 15680, 15681, 15682, 15683, 15684, 15685, 15686, 15687, 
15688, 15689, 15690, 15691, 15692, 15693, 15694, 15695, 15696, 
15697, 15698, 15699, 15700, 15701, 15702, 15703, 15704, 15705, 
15675, 15676, 15677, 15678, 15679, 15680, 15681, 15682, 15683, 
15684, 15685, 15686, 15687, 15688, 15689, 15690, 15691, 15692, 
15693, 15694, 15695, 15696, 15697, 15698, 15699, 15700, 15701, 
15702, 15703, 15704, 15705, 15675, 15676, 15677, 15678, 15679, 
15680, 15681, 15682, 15683, 15684, 15685, 15686, 15687, 15688, 
15689, 15690, 15691, 15692, 15693, 15694, 15695, 15696, 15697, 
15698, 15699, 15700, 15701, 15702, 15703, 15704, 15705, 15675, 
15676, 15677, 15678, 15679, 15680, 15681, 15682, 15683, 15684, 
15685, 15686, 15687, 15688, 15689, 15690, 15691, 15692, 15693, 
15694, 15695, 15696, 15697, 15698, 15699, 15700, 15701, 15702, 
15703, 15704, 15705), class = "Date"), year.month = structure(c(12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L, 12L, 12L), .Label = c("Jan 2012", "Feb 2012", 
"Mar 2012", "Apr 2012", "May 2012", "Jun 2012", "Jul 2012", "Aug 2012", 
"Sep 2012", "Oct 2012", "Nov 2012", "Dec 2012"), class = "factor"), 
    DOW = structure(c(7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 
    3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 
    4L, 5L, 6L, 7L, 1L, 2L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 
    3L, 4L, 5L, 6L, 7L, 1L, 2L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
    1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 
    2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 
    7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
    1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L), .Label = c("Sun", "Mon", 
    "Tue", "Wed", "Thu", "Fri", "Sat"), class = "factor"), variable = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 4L), .Label = c("On Duty to Departure", "Departure to Arrival", 
    "Arrival to Off Duty", "Departure to Off Duty"), class = "factor"), 
    value = c(NA, 1, 1.83333333333333, 3, 2, 1.38333333333333, 
    NA, NA, 1, 1.61666666666667, 1.1, 3.5, 1.53333333333333, 
    NA, NA, 5.5, 3, 1.35, 3.5, 3.5, NA, NA, 1.78333333333333, 
    NA, NA, 0.75, 1.45, NA, NA, 1.13333333333333, NA, NA, NA, 
    0.0666666666666667, 0.0833333333333333, NA, 0.183333333333333, 
    NA, NA, NA, 0.466666666666667, 0.2, 0.35, 0.383333333333333, 
    NA, NA, 0.133333333333333, 0.0166666666666667, NA, 0.0166666666666667, 
    0.183333333333333, NA, NA, 0.2, NA, NA, 0.0166666666666667, 
    0.75, NA, NA, 0.1, NA, NA, NA, 9.41666666666667, 7.83333333333333, 
    NA, 7.61666666666667, NA, NA, NA, 9.3, 7.98333333333333, 
    7.25, 7.8, NA, NA, 4.41666666666667, 8, NA, 6.5, 4.08333333333333, 
    NA, NA, 3.71666666666667, NA, NA, 10.1666666666667, 9.46666666666667, 
    NA, NA, 6.7, NA, NA, 10.4666666666667, NA, NA, 7.95, NA, 
    NA, NA, 6.06666666666667, NA, NA, NA, NA, NA, NA, NA, NA, 
    6.23333333333333, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA), day = c("01", "02", "03", "04", "05", "06", 
    "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", 
    "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", 
    "27", "28", "29", "30", "31", "01", "02", "03", "04", "05", 
    "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", 
    "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", 
    "26", "27", "28", "29", "30", "31", "01", "02", "03", "04", 
    "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", 
    "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", 
    "25", "26", "27", "28", "29", "30", "31", "01", "02", "03", 
    "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", 
    "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", 
    "24", "25", "26", "27", "28", "29", "30", "31")), .Names = c("Date", 
"year.month", "DOW", "variable", "value", "day"), row.names = c(336L, 
337L, 338L, 339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L, 
348L, 349L, 350L, 351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 
359L, 360L, 361L, 362L, 363L, 364L, 365L, 366L, 702L, 703L, 704L, 
705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L, 713L, 714L, 715L, 
716L, 717L, 718L, 719L, 720L, 721L, 722L, 723L, 724L, 725L, 726L, 
727L, 728L, 729L, 730L, 731L, 732L, 1068L, 1069L, 1070L, 1071L, 
1072L, 1073L, 1074L, 1075L, 1076L, 1077L, 1078L, 1079L, 1080L, 
1081L, 1082L, 1083L, 1084L, 1085L, 1086L, 1087L, 1088L, 1089L, 
1090L, 1091L, 1092L, 1093L, 1094L, 1095L, 1096L, 1097L, 1098L, 
1434L, 1435L, 1436L, 1437L, 1438L, 1439L, 1440L, 1441L, 1442L, 
1443L, 1444L, 1445L, 1446L, 1447L, 1448L, 1449L, 1450L, 1451L, 
1452L, 1453L, 1454L, 1455L, 1456L, 1457L, 1458L, 1459L, 1460L, 
1461L, 1462L, 1463L, 1464L), class = "data.frame")

## Old code - Correct order + warning
ggplot(data = data.set,
       aes(x = day,
           y = value,
           fill = variable)) +
    geom_bar(colour = 'black') +
    ylab('Avg Time (hrs)') +
    xlab('Day of the Month') +
    guides(fill = guide_legend(title = ""))


## Order is now broken
ggplot(data = data.set,
       aes(x = day,
           y = value,
           fill = variable)) +
    geom_bar(colour = 'black', stat='identity') +
    ylab('Avg Time (hrs)') +
    xlab('Day of the Month')

## Error with position='fill'
ggplot(data = data.set,
       aes(x = day,
           y = value,
           fill = variable)) +
    geom_bar(colour = 'black', stat='identity', position='fill') +
    ylab('Avg Time (hrs)') +
    xlab('Day of the Month')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:51:19+00:00Added an answer on June 17, 2026 at 9:51 am

    I think this is an example of a known bug: https://github.com/hadley/ggplot2/issues/721

    To work around it and get the original ordering, add an order aesthetic:

    ggplot(data = data.set,
           aes(x = day,
               y = value,
               fill = variable,
               order = variable)) +
        geom_bar(colour = 'black', stat='identity') +
        ylab('Avg Time (hrs)') +
        xlab('Day of the Month')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just updated my django to 1.4. But I am getting the following error
I just updated Maven from 2.0.9 to 2.2.1 and I'm getting the following exception
I just updated PHP 5.2.0 to 5.2.11 and now I am getting loads of
I just updated my app on the play store and i started receiving crash
Facebook just updated chat (yet again) and now a new fixed side bar stays
I just updated Ninject from v3 to v3.0.1.10 using NuGet, and it broke my
Just updated to latest xCode 4.41 and now I'm getting a ton of warnings
I just updated the StudentID and StudentName into the database. I use these following
I just updated my ubuntu 11.10 to 12.04 and getting this problem, my android
I just updated my NuGet Package Manager on my corporate machine. Ever since the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.