Reputation: 1
I would like to produce the attached graph
with the R package agricolae, could someone give me an example with the attached data?
I expect an adapted graph with the data
Upvotes: 0
Views: 214
Reputation: 1922
I think you will need to change to a long data format
library(tidyverse)
df <- data.frame(TREAT = c(rep('t1', 4), rep('t2', 4), rep('t3', 4), rep('t4', 4), rep('t5', 4)),
REP = c(rep(c(1, 2, 3, 4),5)),
VAR1 = c(16.10, 14.10, 5.8, 4.90, 30.80, 29.00, 28.80, 16.60, 31.30, 29.60, 28.10, 19.50, 21.45, 23.60, 25.95, 28.55, 27.70, 13.70, 8.10, 0.00),
VAR2 = c(0.81, 0.71, 0.29, 0.25, 1.54, 1.45, 1.44, 0.83, 1.57, 1.48, 1.41, 0.98, 1.07, 1.18, 1.30, 1.43, 1.37, 0.96, 0.41, 0.00),
VAR3 = c(0.97, 0.85, 0.35, 0.29, 1.85, 1.74, 1.73, 1.00, 1.88, 1.78, 1.69, 1.17, 1.29, 1.42, 1.56, 1.71, 1.64, 0.82, 0.49, 0.00),
VAR4 = c(1.45, 1.27, 0.52, 0.44, 2.77, 2.61, 2.59, 1.49, 2.82, 2.66, 2.53, 1.76, 1.93, 2.12, 2.34, 2.57, 2.46, .123, 0.73, 0.00)
) %>%
pivot_longer(VAR1:VAR4,
names_to = 'VAR')
ggplot(data = df,
mapping = aes(x = VAR,
y = value,
fill = TREAT)) +
geom_col(position = position_dodge()) +
labs(x = 'Apparent recovery efficiency',
y = 'Aboveground biomass cut')
Once you calculate, can use geom_errorbar() to add the bars.
Upvotes: 0