我面对这个问题:我在excel中准备了一个数据表,然后将其作为CSV导出到R。我使用了函数read.csv2。在我设置数据框之后,我尝试排除带有country名称的第一列。
我想绘制和做PC分析,但我被非数值参数问题卡住了。我如何处理它或找到一个可能的非数值因子?错误是:
> pairs(dati)
> Error in pairs.default(dati) : non-numeric argument to 'pairs'更新:
> str(dati)
'data.frame': 184 obs. of 6 variables:
$ Political Stability and Absence of Violence/Terrorism: chr "1.17" "-2.41" "-2.06" "-0.33" ...
$ Government Effectiveness : chr "1.41" "-2.18" "-0.86" "-0.69" ...
$ Voice and Accountability : chr "1.56" "-1.91" "-1.58" "-0.65" ...
$ Rule of Law : chr "1.16" "-1.79" "-1.63" "-0.68" ...
$ Regulatory Quality : chr "1.27" "-2.09" "-1.42" "-0.47" ...
$ Control of Corruption : chr "1.32" "-1.29" "-1.17" "-0.89" ...发布于 2021-10-06 15:03:14
pairs失败,因为您的数据框只有字符列。
我们可以尝试使用type.convert()修复这个问题,它会将所有字符列转换为适当的类。
dati2 <- type.convert(dati, as.is = TRUE)
pairs(dati2)https://stackoverflow.com/questions/69467732
复制相似问题