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 8338889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:43:48+00:00 2026-06-09T04:43:48+00:00

Working from the following dataframe: > foo species density day percent 1 species1 high

  • 0

Working from the following dataframe:

    > foo
        species density day percent  
    1  species1    high   1    0.40  
    2  species1     low   1    0.20  
    3  species1  medium   1    0.40  
    4  species2    high   1    0.35  
    5  species2     low   1    0.10  
    6  species2  medium   1    0.55  
    7  species3    high   1    0.35  
    8  species3     low   1    0.20  
    9  species3  medium   1    0.45  
    10 species4    high   1    0.30  
    11 species4     low   1    0.20  
    12 species4  medium   1    0.50  
    13 species1    high 100    0.50  
    14 species1     low 100    0.40  
    15 species1  medium 100    0.10  
    16 species2    high 100    0.40  
    17 species2     low 100    0.05  
    18 species2  medium 100    0.55  
    19 species3    high 100    0.65  
    20 species3     low 100    0.05  
    21 species3  medium 100    0.30  
    22 species4    high 100    0.40  
    23 species4     low 100    0.20  
    24 species4  medium 100    0.40  

I have created the following faceted bar graph:

require(ggplot2)

foo$density<-factor(foo$density,levels=c('low','medium','high'))

d <- ggplot(foo, aes(x=species, y=percent, fill=density)) +
    geom_bar(aes(width=.65), stat="identity") +
    facet_grid(. ~ day)

enter image description here

However, I would like to merge these graphs to create a single two-factor bar graph. On the x-axis, each day- 1 and 100 – would be grouped by species. Any suggestions on how to create this?

Many thanks!

  • 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-09T04:43:50+00:00Added an answer on June 9, 2026 at 4:43 am

    Try this one

    foo$species_day <- with(data = foo, expr = paste(species, day))
    d <-ggplot(foo, aes(x=species_day, y=percent, fill=density)) +
          geom_bar(aes(width=.65), stat="identity")
    

    enter image description here
    You can rearrange the levels if you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to update a subversion working copy from Netbeans, I get the following
I have been working on the following problem from this book . A certain
The following produces a working select drop down that pulls from my user model:
I've got the following T-SQL code below that's working from inside of SQL Server
I have the following code (I'm working from code at http://www.linuxhowtos.org/C_C++/socket.htm ) which I'm
The following R code generates a snippet from data frame I am working with
The following query is not working from visual Studio: var query = this.ObjectContext.Questions.Include(AnswerKey).Where(o =>
PHP beginner working from a tutorial. I'm trying to do a simple upload from
I'm working from a JavaScript book and would like to create some menus using
I got the chat example working from Atmosphere, and now I want to get

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.