ranovarstatix

Error message when using anova_test() - Error in str2lang(x) : <text>:1:8: unexpected input 1: cbind(1_


When running previously working code with new data I get the following error:

res.aov <- anova_test(
  data = c1_l1, dv = value, wid = Month,
  within = c(buffer, TimePeriod),
  effect.size = "ges",
  detailed = TRUE,
)
# Error in str2lang(x) : <text>:1:10: unexpected input
# 1: cbind(100_

Obviously, this suggests the data is the problem, but I can't see why that might be. The data have been recreated using the same process as previously, prepared in the same way, and as far as I can tell are in the same format and syntax.

Data:

> dput(head(c1_l1))
structure(list(buffer = c(2, 3, 4, 5, 6, 7), date = structure(c(18270, 
18270, 18270, 18270, 18270, 18270), class = "Date"), Year = structure(c(3L, 
3L, 3L, 3L, 3L, 3L), levels = c("2016", "2017", "2020"), class = "factor"), 
    Month = c(1, 1, 1, 1, 1, 1), TimePeriod = structure(c(2L, 
    2L, 2L, 2L, 2L, 2L), levels = c("1", "2"), class = "factor"), 
    variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L), levels = c("lst_c1_l1_lst", 
    "lst_c1_l1_single_lst", "lst_c2_l1_lst", "lst_c2_l1_single_lst", 
    "lst_c2_l2_lst"), class = "factor"), value = c(39.42118494, 
    39.46416636, 39.48439384, 39.49212885, 39.23692955, 39.2688776
    )), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
> str(lst)
'data.frame':   2400 obs. of  7 variables:
 $ buffer    : num  200 200 200 200 200 300 300 300 300 300 ...
 $ date      : Date, format: "2020-01-09" "2020-01-09" "2020-01-09" ...
 $ Year      : Factor w/ 3 levels "2016","2017",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ Month     : num  1 1 1 1 1 1 1 1 1 1 ...
 $ TimePeriod: Factor w/ 2 levels "1","2": 2 2 2 2 2 2 2 2 2 2 ...
 $ variable  : Factor w/ 5 levels "lst_c1_l1_lst",..: 1 2 3 4 5 1 2 3 4 5 ...
 $ value     : num  39.4 39.4 39.7 39.7 39.7 ...

Code:

# Some of the below are not used - subsetted from larger R file
library(ggplot2)
library(ggpubr)
library(tidyverse)
library(rstatix)
library(ez)
library(dplyr)

lst <- read.csv("./Data/By metric/LST/landsat_lsts_long.csv", encoding="UTF-8", check.names = FALSE)
str(lst)

lst$buffer <- as.numeric(lst$buffer)
lst$date <- as.Date(lst$date, format = "%d/%m/%Y")
lst$Year <- as.factor(lst$Year)
lst$Month <- as.numeric(lst$Month)
lst$TimePeriod <- as.factor(lst$TimePeriod)
lst$variable <- as.factor(lst$variable)
#lst$weather_variable <- as.factor(lst$weather_variable)

str(lst)

c1_l1 <- as_tibble(filter(lst, variable == "lst_c1_l1_lst"))

res.aov <- anova_test(
  data = c1_l1, dv = value, wid = Month,
  within = c(buffer, TimePeriod),
  effect.size = "ges",
  detailed = TRUE,
)
get_anova_table(res.aov, correction = "auto")

Can anyone explain the error or suggest a solution?

Edit

Larger sample of data (500 of 2400 rows):

> dput(lst[1:500, ])
structure(list(buffer = c(200, 200, 200, 200, 200, 300, 300, 
300, 300, 300, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 
600, 600, 600, 600, 600, 700, 700, 700, 700, 700, 800, 800, 800, 
800, 800, 900, 900, 900, 900, 900, 1000, 1000, 1000, 1000, 1000, 
1100, 1100, 1100, 1100, 1100, 1200, 1200, 1200, 1200, 1200, 1300, 
1300, 1300, 1300, 1300, 1400, 1400, 1400, 1400, 1400, 1500, 1500, 
1500, 1500, 1500, 1600, 1600, 1600, 1600, 1600, 1700, 1700, 1700, 
1700, 1700, 1800, 1800, 1800, 1800, 1800, 1900, 1900, 1900, 1900, 
1900, 2000, 2000, 2000, 2000, 2000, 100, 100, 100, 100, 100, 
200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 400, 400, 400, 
400, 400, 500, 500, 500, 500, 500, 600, 600, 600, 600, 600, 700, 
700, 700, 700, 700, 800, 800, 800, 800, 800, 900, 900, 900, 900, 
900, 1000, 1000, 1000, 1000, 1000, 1100, 1100, 1100, 1100, 1100, 
1200, 1200, 1200, 1200, 1200, 1300, 1300, 1300, 1300, 1300, 1400, 
1400, 1400, 1400, 1400, 1500, 1500, 1500, 1500, 1500, 1600, 1600, 
1600, 1600, 1600, 1700, 1700, 1700, 1700, 1700, 1800, 1800, 1800, 
1800, 1800, 1900, 1900, 1900, 1900, 1900, 2000, 2000, 2000, 2000, 
2000, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 300, 
300, 300, 300, 300, 400, 400, 400, 400, 400, 500, 500, 500, 500, 
500, 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, 800, 800, 
800, 800, 800, 900, 900, 900, 900, 900, 1000, 1000, 1000, 1000, 
1000, 1100, 1100, 1100, 1100, 1100, 1200, 1200, 1200, 1200, 1200, 
1300, 1300, 1300, 1300, 1300, 1400, 1400, 1400, 1400, 1400, 1500, 
1500, 1500, 1500, 1500, 1600, 1600, 1600, 1600, 1600, 1700, 1700, 
1700, 1700, 1700, 1800, 1800, 1800, 1800, 1800, 1900, 1900, 1900, 
1900, 1900, 2000, 2000, 2000, 2000, 2000, 100, 100, 100, 100, 
100, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 400, 400, 
400, 400, 400, 500, 500, 500, 500, 500, 600, 600, 600, 600, 600, 
700, 700, 700, 700, 700, 800, 800, 800, 800, 800, 900, 900, 900, 
900, 900, 1000, 1000, 1000, 1000, 1000, 1100, 1100, 1100, 1100, 
1100, 1200, 1200, 1200, 1200, 1200, 1300, 1300, 1300, 1300, 1300, 
1400, 1400, 1400, 1400, 1400, 1500, 1500, 1500, 1500, 1500, 1600, 
1600, 1600, 1600, 1600, 1700, 1700, 1700, 1700, 1700, 1800, 1800, 
1800, 1800, 1800, 1900, 1900, 1900, 1900, 1900, 2000, 2000, 2000, 
2000, 2000, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 
300, 300, 300, 300, 300, 400, 400, 400, 400, 400, 500, 500, 500, 
500, 500, 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, 800, 
800, 800, 800, 800, 900, 900, 900, 900, 900, 1000, 1000, 1000, 
1000, 1000, 1100, 1100, 1100, 1100, 1100, 1200, 1200, 1200, 1200, 
1200, 1300, 1300, 1300, 1300, 1300, 1400, 1400, 1400, 1400, 1400, 
1500, 1500, 1500, 1500, 1500, 1600, 1600, 1600, 1600, 1600, 1700, 
1700, 1700, 1700, 1700, 1800, 1800, 1800, 1800, 1800, 1900, 1900, 
1900, 1900, 1900, 2000, 2000, 2000, 2000, 2000, 100, 100, 100, 
100, 100), date = structure(c(18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 18270, 
18270, 18270, 18270, 18270, 18270, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 17182, 
17182, 17182, 17182, 17182, 17182, 17182, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 18302, 
18302, 18302, 18302, 18302, 18302, 18302, 18302, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 
18334, 18334, 18334, 18334, 18334, 18334, 18334, 18334, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 
17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230, 17230
), class = "Date"), Year = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 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 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 
4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 
1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 
4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 
1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L), levels = c("lst_c1_l1_lst", "lst_c1_l1_single_lst", 
"lst_c2_l1_lst", "lst_c2_l1_single_lst", "lst_c2_l2_lst"), class = "factor"), 
    value = c(39.42118494, 39.42118494, 39.69002203, 39.69002203, 
    39.69002203, 39.46416636, 39.46416636, 39.73204192, 39.73204192, 
    39.73204192, 39.48439384, 39.48439384, 39.75312025, 39.75312025, 
    39.75312025, 39.49212885, 39.49212885, 39.77773065, 39.77773065, 
    39.77773065, 39.23692955, 39.23692955, 39.50876672, 39.50876672, 
    39.50876672, 39.2688776, 39.2688776, 39.5308463, 39.5308463, 
    39.5308463, 39.26009488, 39.26009488, 39.51862556, 39.51862556, 
    39.51862556, 39.23362907, 39.23362907, 39.49314495, 39.49314495, 
    39.49314495, 39.22544967, 39.22544967, 39.48686828, 39.48686828, 
    39.48686828, 39.22921385, 39.22921385, 39.49069941, 39.49069941, 
    39.49069941, 39.22121268, 39.22121268, 39.47842417, 39.47842417, 
    39.47842417, 39.25855237, 39.25855237, 39.5177284, 39.5177284, 
    39.5177284, 39.31654836, 39.31654836, 39.57357954, 39.57357954, 
    39.57357954, 39.29034224, 39.29034224, 39.54928469, 39.54928469, 
    39.54928469, 39.21842964, 39.21842964, 39.48037064, 39.48037064, 
    39.48037064, 39.18790111, 39.18790111, 39.43845258, 39.43845258, 
    39.43845258, 39.15256059, 39.15256059, 39.41036294, 39.41036294, 
    39.41036294, 39.11216125, 39.11216125, 39.36755125, 39.36755125, 
    39.36755125, 39.08030747, 39.08030747, 39.33167812, 39.33167812, 
    39.33167812, 39.12993955, 39.12993955, 39.39689619, 39.39689619, 
    39.39689619, 43.8048763, 43.8048763, 44.17214494, 44.17214494, 
    44.17214494, 43.77706328, 43.77706328, 44.14471764, 44.14471764, 
    44.14471764, 43.76715395, 43.76715395, 44.12919958, 44.12919958, 
    44.12919958, 43.6734276, 43.6734276, 44.03295273, 44.03295273, 
    44.03295273, 43.43969325, 43.43969325, 43.79043297, 43.79043297, 
    43.79043297, 43.46617317, 43.46617317, 43.82164862, 43.82164862, 
    43.82164862, 43.45817407, 43.45817407, 43.81200158, 43.81200158, 
    43.81200158, 43.49256715, 43.49256715, 43.86329877, 43.86329877, 
    43.86329877, 43.49382639, 43.49382639, 43.86636556, 43.86636556, 
    43.86636556, 43.48534435, 43.48534435, 43.85745411, 43.85745411, 
    43.85745411, 43.38213544, 43.38213544, 43.75286456, 43.75286456, 
    43.75286456, 43.3023932, 43.3023932, 43.6661483, 43.6661483, 
    43.6661483, 43.24328463, 43.24328463, 43.60471125, 43.60471125, 
    43.60471125, 43.09468321, 43.09468321, 43.44744563, 43.44744563, 
    43.44744563, 42.94489759, 42.94489759, 43.29081306, 43.29081306, 
    43.29081306, 42.85892867, 42.85892867, 43.19730725, 43.19730725, 
    43.19730725, 42.76776694, 42.76776694, 43.10273585, 43.10273585, 
    43.10273585, 42.68127243, 42.68127243, 43.01059651, 43.01059651, 
    43.01059651, 42.66140238, 42.66140238, 42.99118471, 42.99118471, 
    42.99118471, 43.70369864, 43.70369864, 44.07106004, 44.07106004, 
    44.07106004, 36.70611252, 36.70611252, 36.9107136, 36.9107136, 
    36.9107136, 36.72775555, 36.72775555, 36.92395327, 36.92395327, 
    36.92395327, 36.74749898, 36.74749898, 36.93449529, 36.93449529, 
    36.93449529, 36.6533153, 36.6533153, 36.83617274, 36.83617274, 
    36.83617274, 36.44506508, 36.44506508, 36.63608161, 36.63608161, 
    36.63608161, 36.43721713, 36.43721713, 36.62929251, 36.62929251, 
    36.62929251, 36.43733177, 36.43733177, 36.62324992, 36.62324992, 
    36.62324992, 36.43583453, 36.43583453, 36.61967969, 36.61967969, 
    36.61967969, 36.40827146, 36.40827146, 36.589868, 36.589868, 
    36.589868, 36.3907843, 36.3907843, 36.57116139, 36.57116139, 
    36.57116139, 36.35854057, 36.35854057, 36.54628954, 36.54628954, 
    36.54628954, 36.40712661, 36.40712661, 36.59210861, 36.59210861, 
    36.59210861, 36.43340117, 36.43340117, 36.60861537, 36.60861537, 
    36.60861537, 36.31455504, 36.31455504, 36.48974973, 36.48974973, 
    36.48974973, 36.22447072, 36.22447072, 36.39436863, 36.39436863, 
    36.39436863, 36.21140555, 36.21140555, 36.38112795, 36.38112795, 
    36.38112795, 36.19563266, 36.19563266, 36.35853431, 36.35853431, 
    36.35853431, 36.16204925, 36.16204925, 36.32527651, 36.32527651, 
    36.32527651, 36.16206731, 36.16206731, 36.3293186, 36.3293186, 
    36.3293186, 36.43714217, 36.43714217, 36.622595, 36.622595, 
    36.622595, 28.09393998, 28.09393998, 28.15452004, 28.15452004, 
    28.15452004, 28.05127491, 28.05127491, 28.10864511, 28.10864511, 
    28.10864511, 28.02972073, 28.02972073, 28.04448871, 28.04448871, 
    28.04448871, 28.03610704, 28.03610704, 28.04071712, 28.04071712, 
    28.04071712, 28.02902252, 28.02902252, 27.99060337, 27.99060337, 
    27.99060337, 28.05021483, 28.05021483, 28.01166398, 28.01166398, 
    28.01166398, 28.03387381, 28.03387381, 27.9922879, 27.9922879, 
    27.9922879, 27.96075552, 27.96075552, 27.90532568, 27.90532568, 
    27.90532568, 27.92236376, 27.92236376, 27.87621457, 27.87621457, 
    27.87621457, 27.88527292, 27.88527292, 27.87611205, 27.87611205, 
    27.87611205, 27.84768492, 27.84768492, 27.85894957, 27.85894957, 
    27.85894957, 27.83940352, 27.83940352, 27.84847982, 27.84847982, 
    27.84847982, 27.81627322, 27.81627322, 27.82635454, 27.82635454, 
    27.82635454, 27.7815786, 27.7815786, 27.77298566, 27.77298566, 
    27.77298566, 27.76044908, 27.76044908, 27.73830099, 27.73830099, 
    27.73830099, 27.74557724, 27.74557724, 27.73498831, 27.73498831, 
    27.73498831, 27.67807817, 27.67807817, 27.73279985, 27.73279985, 
    27.73279985, 27.68961021, 27.68961021, 27.7333632, 27.7333632, 
    27.7333632, 27.72383966, 27.72383966, 27.77542992, 27.77542992, 
    27.77542992, 27.94160345, 27.94160345, 27.97709364, 27.97709364, 
    27.97709364, 32.44370349, 32.44370349, 32.50556817, 32.50556817, 
    32.50556817, 32.36811356, 32.36811356, 32.43038012, 32.43038012, 
    32.43038012, 32.38152433, 32.38152433, 32.43476867, 32.43476867, 
    32.43476867, 32.36183697, 32.36183697, 32.40781406, 32.40781406, 
    32.40781406, 32.29013031, 32.29013031, 32.33402053, 32.33402053, 
    32.33402053, 32.33718591, 32.33718591, 32.3814359, 32.3814359, 
    32.3814359, 32.33472529, 32.33472529, 32.38747789, 32.38747789, 
    32.38747789, 32.3284777, 32.3284777, 32.38604191, 32.38604191, 
    32.38604191, 32.31624064, 32.31624064, 32.37249513, 32.37249513, 
    32.37249513, 32.30115037, 32.30115037, 32.35506708, 32.35506708, 
    32.35506708, 32.22876705, 32.22876705, 32.28006241, 32.28006241, 
    32.28006241, 32.16531796, 32.16531796, 32.21779251, 32.21779251, 
    32.21779251, 32.13354855, 32.13354855, 32.18199623, 32.18199623, 
    32.18199623, 32.04679917, 32.04679917, 32.08793194, 32.08793194, 
    32.08793194, 31.95865036, 31.95865036, 31.99349115, 31.99349115, 
    31.99349115, 31.89786652, 31.89786652, 31.92950005, 31.92950005, 
    31.92950005, 31.8230681, 31.8230681, 31.85623561, 31.85623561, 
    31.85623561, 31.746572, 31.746572, 31.78002994, 31.78002994, 
    31.78002994, 31.72857776, 31.72857776, 31.7725018, 31.7725018, 
    31.7725018, 32.4731662, 32.4731662, 32.53562016, 32.53562016, 
    32.53562016)), row.names = c(NA, 500L), class = "data.frame")

Solution

  • BLUF: anova_test requires factors in wid= and within=, and uses the values to form names, so the first in within= must not start with a number.

    How to find this problem:

    1. Look in the source for cbind and see that that package forms an expression by string concatenation (found in factorial_design). This is generally a bad idea when you don't control the data, and your issue here is a good example why. (I suggest you submit a bug report from this question.)

    2. debugonce(factorial_design), then evaluate your call to anova_test. Since the string-forming expression in factorial_design is using wide.dv.name, we'll step through until that is defined.

    3. Look at the value:

      wide.dv.name
      # [1] "100_1, 100_2, 1000_1, 1000_2, 1100_1, 1100_2, 1200_1, 1200_2, 1300_1, 1300_2, 1400_1, 1400_2, 1500_1, 1500_2, 1600_1, 1600_2, 1700_1, 1700_2, 1800_1, 1800_2, 1900_1, 1900_2, 200_1, 200_2, 2000_1, 2000_2, 300_1, 300_2, 400_1, 400_2, 500_1, 500_2, 600_1, 600_2, 700_1, 700_2, 800_1, 800_2, 900_1, 900_2"
      lm_formula
      # [1] "cbind(100_1, 100_2, 1000_1, 1000_2, 1100_1, 1100_2, 1200_1, 1200_2, 1300_1, 1300_2, 1400_1, 1400_2, 1500_1, 1500_2, 1600_1, 1600_2, 1700_1, 1700_2, 1800_1, 1800_2, 1900_1, 1900_2, 200_1, 200_2, 2000_1, 2000_2, 300_1, 300_2, 400_1, 400_2, 500_1, 500_2, 600_1, 600_2, 700_1, 700_2, 800_1, 800_2, 900_1, 900_2) ~ 1"
      

    Okay, so that is clearly not good, R doesn't like variables starting with a number. These are formed from wide.

    Looking at the problem values 100_1 and such, these are formed from buffer and Month, your arguments to within=. Reading the docs for anova_test, we see

      within: (optional) within-subjects factor variables
    

    while our buffer (and TimePeriod) are not factors. Since this problem is unlikely to happen if buffer (the leading portion of the strings formed) started with other than a number character, we'll focus on that. We can try to form a factor (not changing the contents), but I doubt it'll work since there does not appear to be any validation code in there that differentiates numbers from factors:

    c1_l1$bufferf <- factor(c1_l1$buffer)
    res.aov <- anova_test(
      data = c1_l1, dv = value, wid = Month,
      within = c(bufferf, TimePeriod),
      effect.size = "ges",
      detailed = TRUE,
    )
    # Error in str2lang(x) : <text>:1:10: unexpected input
    # 1: cbind(100_
    

    Okay, confirmed. Let's try prepending buffer with a letter. I'll fast-forward to make the following changes:

    c1_l1$buffer_chr <- factor(paste0("b", c1_l1$buffer))
    c1_l1$TimePeriod_fct <- factor(c1_l1$TimePeriod)
    c1_l1$Month_fct <- factor(c1_l1$Month)
    res.aov <- anova_test(
      data = c1_l1, dv = value, wid = Month_fct,
      within = c(buffer_chr, TimePeriod_fct),
      effect.size = "ges",
      detailed = TRUE,
    )
    # Error in eigen(SSPE, only.values = TRUE)$values >= sqrt(.Machine$double.eps) : 
    #   invalid comparison with complex values
    

    But frankly that is a completely different error, and may be resolved with more complete data or through other aspects of your analysis/exploration.