Anova_test 的函数找不到列或给我错误

问题描述 投票:0回答:0

我正在尝试使用此数据框对我的数据运行方差分析

df = structure(list(Total_Devices = c(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, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), Tracking_Group = c(Stationary_Acoustic = "Acoustic", 
Stationary_Acoustic = "Acoustic", Stationary_Acoustic = "Acoustic", 
Stationary_Acoustic = "Acoustic", Stationary_Archival = "Archival", 
Stationary_Acoustic = "Acoustic", Stationary_Acoustic = "Acoustic", 
Stationary_Acoustic = "Acoustic", Stationary_Acoustic = "Acoustic", 
Stationary_Radio = "Radio", Stationary_Acoustic = "Acoustic", 
Stationary_Acoustic = "Acoustic", Stationary_Acoustic = "Acoustic", 
Controlled_Acoustic = "Acoustic", Stationary_Archival = "Archival", 
Controlled_Acoustic = "Acoustic", BRUV_Acoustic = "Acoustic", 
Stationary_Acoustic = "Acoustic", Stationary_Acoustic = "Acoustic", 
Animalborne_Acoustic = "Acoustic", Controlled_Acoustic = "Acoustic", 
Animalborne_Archival = "Archival", Stationary_Acoustic = "Acoustic", 
Stationary_Acoustic = "Acoustic", Animalborne_Archival = "Archival", 
BRUV_Acoustic = "Acoustic", Animalborne_Archival = "Archival", 
Animalborne_Archival = "Archival", Animalborne_Archival = "Archival", 
BRUV_Acoustic = "Acoustic", Controlled_Acoustic = "Acoustic", 
Stationary_Satellite = "Satellite", Animalborne_Archival = "Archival", 
Stationary_Acoustic = "Acoustic", Controlled_Acoustic = "Acoustic", 
Animalborne_Archival = "Archival", BRUV_Acoustic = "Acoustic", 
Controlled_Acoustic = "Acoustic", Animalborne_Archival = "Archival", 
Animalborne_Satellite = "Satellite", Animalborne_Archival = "Archival", 
Animalborne_Archival = "Archival", Animalborne_Archival = "Archival", 
Animalborne_Archival = "Archival", Animalborne_Archival = "Archival", 
Controlled_Archival = "Archival", Animalborne_Archival = "Archival", 
Controlled_Acoustic = "Acoustic", Controlled_Satellite = "Satellite", 
Stationary_Acoustic = "Acoustic", Stationary_Archival = "Archival", 
Stationary_PIT = "PIT", Stationary_Radio = "Radio", Stationary_Satellite = "Satellite", 
Stationary_Acoustic_Archival = "Acoustic", Stationary_Acoustic_Archival = "Acoustic", 
Stationary_Acoustic_PIT = "Acoustic", Stationary_Acoustic_Archival = "Acoustic", 
Stationary_Acousitc_PIT = "PIT", BRUV_Acoustic_Satellite = "Acoustic", 
Stationary_Acoustic_Radio = "Acoustic", BRUV_Acoustic_Satellite = "Acoustic", 
Stationary_Radio_PIT = "PIT", Stationary_Acoustic_Archival = "Acoustic", 
Animalborne_Satellite_Archival = "Archival", Animalborne_Acoustic_Archival = "Acoustic", 
Animalborne_Satellite_Archival = "Archival", Animalborne_Satellite_Archival = "Archival", 
Animalborne_Archival_PIT = "PIT"), size_range = c(0.954242509439325, 
1.88874096068289, 1.66745295288995, 0.544068044350276, 0.556302500767287, 
0.845098040014257, 1.56229286445647, 1, 1.3541084391474, 1.83884909073726, 
0.778151250383644, 1.07918124604762, 1.02118929906994, 0.903089986991944, 
0.954242509439325, 0.845098040014257, 1.47712125471966, 1.87794695162919, 
0.301029995663981, 1.7419390777292, 0.690196080028514, 1.75815462196739, 
1.19865708695442, 1.36172783601759, 1.36735592102602, 1.41497334797082, 
1.41830129131975, NA, 1.53147891704226, 1.95424250943932, 1.43933269383026, 
1.7160033436348, 1.97772360528885, NA, 2.21218760440396, 1.99563519459755, 
2.3747483460101, 2.08278537031645, NA, 2.77815125038364, 2.03342375548695, 
1.95424250943932, 1.95424250943932, NA, NA, 4.56110138364906, 
NA, NA, NA, NA, NA, NA, NA, NA, 0.361727836017593, 1.26717172840301, 
0.944482672150168, 1.32221929473392, 1.57749179983723, 2.00860017176192, 
1.00432137378264, 2.52633927738984, 1.38021124171161, 1.34242268082221, 
NA, 2.31175386105575, 2.30102999566398, NA, NA)), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -69L), groups = structure(list(
    Total_Devices = 2:3, .rows = structure(list(1:54, 55:69), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -2L), .drop = TRUE))

我试过使用这个代码

res = anova_test(data = df,
                 dv = size_range,
                 within = Total_Devices)

但我收到此错误消息

Error in `mutate()`:
! Problem while computing `data = map(.data$data, .f, ...)`.
Caused by error in `map()`:
ℹ In index: 1.
Caused by error in `.args$data[, model.variables]`:
! Can't subset columns that don't exist.
✖ Column `Total_Devices` doesn't exist.
Run `rlang::last_error()` to see where the error occurred.

我也试过使用这个代码

res = anova_test(data = df,
                 dv = df$size_range,
                 within = df$Total_Devices)

但我收到此错误消息

Error in `map()`:
ℹ In index: 1.
ℹ With name: dv.
Caused by error:
! Can't subset columns with `df$size_range`.
✖ Can't convert from `df$size_range` <double> to <integer> due to loss of precision.
Run `rlang::last_error()` to see where the error occurred

我也尝试将列更改为

numeric
factors
但我仍然收到相同的错误消息。

是因为这应该通过 t 检验来运行吗?

r anova
© www.soinside.com 2019 - 2024. All rights reserved.