> complete_data <- data[complete.cases(data),] > rdbwselect(y = complete_data$ALL, x = complete_data$ID, all = TRUE) Error in if (mass_l >= 0.2 | mass_r >= 0.2) { : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In min(X_l) : no non-missing arguments to min; returning Inf 2: In max(X_l) : no non-missing arguments to max; returning -Inf
时间: 2023-07-14 22:12:59 浏览: 62
这个错误可能是因为数据集中存在缺失值,导致在执行 `complete.cases` 函数时删除了包含缺失值的行,因此在后续的函数中出现了错误。建议检查数据集中是否存在缺失值,如果存在,可以使用其他方法进行处理,如填充缺失值或者删除包含缺失值的列。另外,也可以尝试使用 `na.action` 参数来处理缺失值,例如使用 `na.omit` 函数。
相关问题
> complete_data <- na.omit(data) > rdbwselect(y = complete_data$ALL, x = complete_data$ID, all = TRUE) Error in if (mass_l >= 0.2 | mass_r >= 0.2) { : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In min(X_l) : no non-missing arguments to min; returning Inf 2: In max(X_l) : no non-missing arguments to max; returning -Inf
这个错误可能是因为你的数据中有缺失值。在执行`na.omit(data)`时,可能会删除一些行,因此在执行`rdbwselect()`时,会出现缺失值。可以尝试使用`complete.cases()`函数来删除包含缺失值的行,例如:
```
complete_data <- data[complete.cases(data),]
rdbwselect(y = complete_data$ALL, x = complete_data$ID, all = TRUE)
```
如果还是出现错误,可以检查`complete_data$ALL`和`complete_data$ID`是否包含正确的数据类型和格式。
> optdigits <- read.csv("/Users/jiawen/Desktop/optdigits_csv.csv") > optdigits_dist <- dist(optdigits[,1:1038]) Error in `[.data.frame`(optdigits, , 1:1038) : undefined columns selected > optdigits <- optdigits[complete.cases(optdigits),] > optdigits_dist <- dist(optdigits[,1:1038]) Error in `[.data.frame`(optdigits, , 1:1038) : undefined columns selected > optdigits_dist <- dist(optdigits[,1:3]) > mds <- cmdscale(optdigits_dist) > cols <- rainbow(10) > plot(mds,col=cols[optdigits$class+1])为什么mds图像里什么也没有
这个问题可能是因为在距离矩阵计算时,使用了过多的特征列。根据您的代码,您试图计算前1038列的距离矩阵,但是optdigits数据集只有64列。因此,您应该使用正确的列数来计算距离矩阵。例如,如果您只想使用前3列的特征来计算距离矩阵,则可以使用以下代码:
```
optdigits_dist <- dist(optdigits[,1:3])
```
如果您仍然无法得到正确的图像,您可以尝试绘制不同的维度。例如,您可以尝试绘制前两个维度:
```
plot(mds[,1], mds[,2], col=cols[optdigits$class+1])
```
希望这可以帮助您解决问题。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)