ed_二分法):所有参数的长度必须相同。我将变量的数量从75改为222。问题在于长度(综合预测$y)和长度(综合预测$Sladep\u z\u预测的二分法)是不同的。他们不应该这样做。{除非类(combined_predictions$slademport

ed_二分法):所有参数的长度必须相同。我将变量的数量从75改为222。问题在于长度(综合预测$y)和长度(综合预测$Sladep\u z\u预测的二分法)是不同的。他们不应该这样做。{除非类(combined_predictions$slademport,r,R,ed_二分法):所有参数的长度必须相同。我将变量的数量从75改为222。问题在于长度(综合预测$y)和长度(综合预测$Sladep\u z\u预测的二分法)是不同的。他们不应该这样做。{除非类(combined_predictions$slademport_z_predicted)不是“数值”或与y大小不同}我发现在我的第二段代码中有一个额外的空间。但这不应该是问题所在。我重新运行了代码,没有错误。检查类(组合预测值$y)、类(组合预测值$Sladep\u z\u predicted)和类(组合


ed_二分法):所有参数的长度必须相同。我将变量的数量从75改为222。问题在于长度(综合预测$y)和长度(综合预测$Sladep\u z\u预测的二分法)是不同的。他们不应该这样做。{除非类(combined_predictions$slademport_z_predicted)不是“数值”或与y大小不同}我发现在我的第二段代码中有一个额外的空间。但这不应该是问题所在。我重新运行了代码,没有错误。检查类(组合预测值$y)、类(组合预测值$Sladep\u z\u predicted)和类(组合预测值$Sladep\u z\u predicted\u Dictomy)是否都是数字。我假设当你说“我将变量数从75改为222”时,是关于行数的。检查是否有更多行,每行有y和z预测值。
combined_predicitons <- data.frame(landslide_z_predicted, ytest)
combined_predicitons$landslide_z_predicted_dicotomy = round(combined_predicitons$landslide_z_predicted)
threshold = 0.5    
combined_predicitons$landslide_z_predicted_dicotomy = ifelse(combined_predicitons$landslide_z_predicted >= threshold, 1, 0)
table(combined_predicitons$y, combined_predicitons$landslide_z_predicted_dicotomy)
library(dplyr)

# generate sample data
df <- data.frame(landslide_z_predicted=runif(75), y=sample(c(0, 1), 75, replace=T))

# add is_correct and case variables to the data frame
df <- df %>%
  mutate(is_correct = case_when((landslide_z_predicted < 0.5) & !y ~ TRUE,
                                (landslide_z_predicted >= 0.5) & y ~ TRUE,
                                TRUE ~ FALSE)) %>%
 mutate(case = case_when((landslide_z_predicted < 0.5) & !y & is_correct ~ "case_01",
                          (landslide_z_predicted < 0.5) & y & !is_correct ~ "case_02",
                          (landslide_z_predicted >= 0.5) & y & is_correct ~ "case_03",
                          (landslide_z_predicted >= 0.5) & !y & !is_correct ~ "case_04"))

# count the occurrences of the cases
df %>% select(case) %>% group_by(case) %>% summarize(count=n())