starting from nothing and have no idea where to start to make a simple bar graph ggplot2

Hi Everyone,

Could someone please help me. I am new to RStudio and having a lot of problems trying to figure out how to make a simple bar graph like the one I made using excel below (png attached):

image
\\\\\\\\\
data

A tibble: 528 x 6

...1 Ô..Unique_code          Replicate Compound    Compound2 Concentration


1 1 75-210614_GERYAF1.CDF 1 Geraniol B.Pinene 0.00752
2 2 76-210614_GERYAF2.CDF 2 Geraniol B.Pinene 0.00706
3 3 77-210614_GERYAF3.CDF 3 Geraniol B.Pinene 0.00719
4 4 87-210614_NERYAF1.CDF 1 Nerol B.Pinene 0.00758
5 5 88-210614_NERYAF2.CDF 2 Nerol B.Pinene 0.00775
6 6 89-210614_NERYAF3.CDF 3 Nerol B.Pinene 0.00786
7 7 102-210615_CLOLYAF1.CDF 1 Citronellol B.Pinene 0.00584
8 8 103-210615_CLOLYAF2.CDF 2 Citronellol B.Pinene 0.00816
9 9 104-210615_CLOLYAF3.CDF 3 Citronellol B.Pinene 0.00671
10 10 123-210630_CITYAF1.CDF 1 Citral B.Pinene 0.00816

… with 518 more rows

\\\\\\\\\\\\\\\
I would like to be able to produce a graph and be specific about which compound 2 is plotted.

Would anyone be able to help?

Thanks
Rebecca

You can study this excellent resource:
3 Data visualisation | R for Data Science (had.co.nz)

Thank you for the resource- I have gone through and created this plot which isnt quiet what I am after

'''''''ggplot(data = Terpenedata) +
geom_bar(mapping = aes(x = Compound2, y = Concentration), stat = "identity")+
facet_wrap(~ Compound, nrow = 2)
""""""""""""""""

I would like to include the mean and standard deviation of the "Compound" and select the "Compound2" that is plotted (the options with the highest concentration

We don't have your Terpenedata.I don't think we need all of it, but 'some' of it would be useful. Maybe pick 2 of your Compound and share just the data for those.
FAQ: How to do a minimal reproducible example ( reprex ) for beginners - meta / Guides & FAQs - RStudio Community

head(Terpenedata,50)[c('Compound','Compound2','Concentration')]

datapasta::df_paste(head(Terpenedata,50)[c('Compound','Compound2','Concentration')])
data.frame(
  stringsAsFactors = FALSE,
          Compound = c("Geraniol","Geraniol",
                       "Geraniol","Nerol","Nerol","Nerol","Citronellol",
                       "Citronellol","Citronellol","Citral","Citral","Citral",
                       "A.terpineol","A.terpineol","A.terpineol",
                       "Citronellyl.acetate","Citronellyl.acetate","Citronellyl.acetate",
                       "Humulene","Humulene","Humulene","Caryophyllene",
                       "Caryophyllene","Caryophyllene","Linalool","Linalool","Linalool",
                       "Limonene","Limonene","Limonene","B.pinene",
                       "B.pinene","B.pinene","Geraniol","Geraniol","Geraniol",
                       "Nerol","Nerol","Nerol","Citronellol","Citronellol",
                       "Citronellol","Citral","Citral","Citral","A.terpineol",
                       "A.terpineol","A.terpineol","Citronellyl.acetate",
                       "Citronellyl.acetate"),
         Compound2 = c("B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","Myrcene","Myrcene","Myrcene",
                       "Myrcene","Myrcene","Myrcene","Myrcene","Myrcene",
                       "Myrcene","Myrcene","Myrcene","Myrcene","Myrcene",
                       "Myrcene","Myrcene","Myrcene","Myrcene"),
     Concentration = c(0.007520654,0.007064241,
                       0.007192582,0.00757695,0.007753056,0.007858232,0.005841789,
                       0.008161947,0.006714852,0.008162053,0.008662327,
                       0.008052792,0.008079217,0.008841989,0.008212932,
                       0.00532694,0.004587573,0.004048106,0.005714935,0.005479401,
                       0.005568608,0.006526013,0.005617379,0.006967101,
                       0.009495839,0.013968538,0.009086078,0.03704854,0.042965721,
                       0.026089159,1.659645278,1.742959751,1.762389877,
                       0.006956027,0.008250725,0.006916001,0.006447971,
                       0.005599035,0.006193504,0.004447824,0.003573527,0.003774742,
                       0.009559275,0.011485213,0.010594831,0.001777776,
                       0.001734115,0.001741081,0.00364551,0.003762947)
)

Just a side note to help you with code formatting for the forum.
the code format symbols are back ticks, whereas I've seen you've been using apostrophes.
Its also best if the triple back ticks are on their own line, defining the break between non formatted and formatted text.

U+0027 APOSTROPHE character (')
U+0060 GRAVE ACCENT character (`)  <- backticks for code formatting

Thank you nirgrahamuk

data.frame(
  stringsAsFactors = FALSE,
          Compound = c("Geraniol","Geraniol",
                       "Geraniol","Nerol","Nerol","Nerol","Citronellol",
                       "Citronellol","Citronellol","Citral","Citral","Citral",
                       "A.terpineol","A.terpineol","A.terpineol",
                       "Citronellyl.acetate","Citronellyl.acetate","Citronellyl.acetate",
                       "Humulene","Humulene","Humulene","Caryophyllene",
                       "Caryophyllene","Caryophyllene","Linalool","Linalool","Linalool",
                       "Limonene","Limonene","Limonene","B.pinene",
                       "B.pinene","B.pinene","Geraniol","Geraniol","Geraniol",
                       "Nerol","Nerol","Nerol","Citronellol","Citronellol",
                       "Citronellol","Citral","Citral","Citral","A.terpineol",
                       "A.terpineol","A.terpineol","Citronellyl.acetate",
                       "Citronellyl.acetate"),
         Compound2 = c("B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","B.Pinene","B.Pinene","B.Pinene",
                       "B.Pinene","B.Pinene","Myrcene","Myrcene","Myrcene",
                       "Myrcene","Myrcene","Myrcene","Myrcene","Myrcene",
                       "Myrcene","Myrcene","Myrcene","Myrcene","Myrcene",
                       "Myrcene","Myrcene","Myrcene","Myrcene"),
     Concentration = c(0.007520654,0.007064241,
                       0.007192582,0.00757695,0.007753056,0.007858232,0.005841789,
                       0.008161947,0.006714852,0.008162053,0.008662327,
                       0.008052792,0.008079217,0.008841989,0.008212932,
                       0.00532694,0.004587573,0.004048106,0.005714935,0.005479401,
                       0.005568608,0.006526013,0.005617379,0.006967101,
                       0.009495839,0.013968538,0.009086078,0.03704854,0.042965721,
                       0.026089159,1.659645278,1.742959751,1.762389877,
                       0.006956027,0.008250725,0.006916001,0.006447971,
                       0.005599035,0.006193504,0.004447824,0.003573527,0.003774742,
                       0.009559275,0.011485213,0.010594831,0.001777776,
                       0.001734115,0.001741081,0.00364551,0.003762947)

Are you trying to plot multiple bar heights for a given Compound ? or a single summarised value ?

Im trying to plot multiple bar plots for each compound -
For example for Compound Geraniol a bar plot for the Compound2 with the 5 highest mean concentration

Screen Shot 2022-03-09 at 2.55.15 PM

Overall this is what I am trying to get for each "Compound"

Is your data post summarisation? i.e have you identified the 5 highest concentrations per group of interest and the data you shared is the result ? or are you asking for help with that aspect ?

I have not summarised that part of the data - is it possible on R or should I deleted it on the excel?