0

I am just starting to work with R and I want to make a column bargraph comparing the density of individuals for 3 different species over multiple months. Every time I enter the code for making a bargraph it outputs a graph with all the same y-values for each species in every month. The code I used is below. I first had to gather my data utilizing tidyr in order to make the graph as the data was organized by a column for each individual species. How can I make the bargraph display my y-values for each data point? Thanks.

ggplot(Bargraphstuff, aes(fill=Species, y='Density per 10 cm Octocoral', x=Month)) + 
  geom_bar(position="dodge", stat="identity") 
camille
  • 16,432
  • 18
  • 38
  • 60
  • 1
    Can you share a sample of the data for clarification? Follow this [link](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for tips on how to share your data. – Kris Nov 20 '19 at 19:05
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. It looks like you are trying to pass a y label as an aesthetic. Maybe you just want `aes(fill=Species, x=Month)` and then at the end put `+ylab('Density per 10 cm Octocoral')` – MrFlick Nov 20 '19 at 19:05
  • Hey Josh, try aes_string(fill='Species', y='Density per 10 cm Octocoral', x='Month'). You are passing a string 'Density per 10 cm Octocoral' as a y value, hence you get always the same output – StupidWolf Nov 20 '19 at 21:23

0 Answers0