data <- data.frame(income = c(23, 24, 27, 31, 20, 22, 22, 27, 25, 29, 43, 37, 41, 42, 45, 45, 46, 31, 26, 37, 41, 30, 47, 45, 45, 48, 37),education = factor(rep(c("high school or lower", "undergraduate", "master or higher"), c(8, 9, 8)))) Error in data.frame(income = c(23, 24, 27, 31, 20, 22, 22, 27, 25, 29, : 参数值意味着不同的行数: 27, 25怎么解决
时间: 2023-07-27 10:25:50 浏览: 228
redisson-spring-data-22-3.12.5-API文档-中英对照版.zip
这个错误是因为在创建 data frame 时,income 和 education 的输入向量长度不一致。可以通过将输入向量的长度调整为相同来解决这个问题,例如:
```
income <- c(23, 24, 27, 31, 20, 22, 22, 27, 25, 29, 43, 37, 41, 42, 45, 45, 46, 31, 26, 37, 41, 30, 47, 45, 45, 48, 37)
education <- factor(rep(c("high school or lower", "undergraduate", "master or higher"), times = c(8, 9, 8))[1:length(income)])
data <- data.frame(income = income, education = education)
```
这样就可以创建一个包含相同长度输入向量的 data frame 了。
阅读全文