0
library(ggplot2)
library(ggpubr)
library(tidyverse)
library(broom)
library(AICcmodavg)

my_data <- read.table(file = "clipboard", 
                      sep = "\t", header=TRUE)


my_data %>%
  mutate(across(CO2, ~ suppressWarnings(as.numeric(.)))) %>%
  group_by(habitat) %>%
  summarise(
    count = n(),
    mean = mean(CO2, na.rm = TRUE),
    sd = sd(CO2, na.rm = TRUE)  )


#library("ggpubr")
ggboxplot(my_data, x = "habitat", y = "CO2", 
color = "habitat", palette = c("#00AFBB", "#E7B800", "#FC4E07", "#0080FF"),
order = c( "Bog", "Fen", "Peatland", "Woodland" ), main="Carbon Abatement in Restored Habitats",
ylab = "Carbon Abatement(t CO2e ha-1 y-1) ", xlab = "Habitat")



res.aov <- aov(co2~ habitat, data = my_data)

summary(res.aov)

Running an ANOVA test and I keep getting the following error- Error in model.frame.default(formula = co2 ~ habitat, data = my_data, : variable lengths differ (found for 'habitat')

Previously this code worked when I used it some weeks ago, but running it again without any changes seems to result in the following issue. What could the problem be? Have seen other similar questions but struggling to relate. Thanks! Dataset: enter image description here

  • It looks like you're fairly new to SO; welcome to the community! If you want great answers quickly, it's best to make your question reproducible. This includes sample data like the output from `dput(head(dataObject)))`. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). This issue is probably due to the data that you didn't include here. – Kat Feb 21 '22 at 21:45

0 Answers0