help with stacked barchart

Hi,

I'm trying to create a stacked barchart but i cant get it to work.
I took some percentages of aquatic plants and how much each species covered the pond water surface. I have 11 ponds in total and I wanted to compare what was seen in each pond by using the stacked barchart.

I've added a picture of the data im using, i have a lot more but i tried to make it smaller so its easier to use.
i'm not a pro at coding but i do have ggplot installed.

i want each bar to be a pond number then within each bar i want the percent of each plant seen.

With only a picture of your data, it is hard to provide tested code. For a sketch of how to make the plot.

  1. Read in the data
  2. Use pivot_longer from the tidyr R package to reshape the data to have four columns: SurveyNo, PondNo, Species, Value. Let's call that data DF
  3. Use the command ggplot(DF, aes(x = PondNo, y = Value, fill = Species)) + geom_col()

For more specific help, please post the output of the dput() function

dput(DATA)

where DATA is the data shown in your first post.

hi,

thanks for getting back to me! i've never used tidyr before so im unsure how to reshape data so i tried in excel. Since there is multiplpe values for each species i'm unsure what im meant to put in the value column you suggested. i tried it in the bottom left of the photo (when uploadinig to r i would put it in its own excel doc).

i could try and upload my data for you? if that would help?

I do not use Excel, but I expect reshaping the data there would be difficult.

If you have read the data into R, please post the output of either

dput(DATA)

or
dput(head(DATA,12))

where you replace _DATA_ with the name of the variable that contains your data.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.