我试图运行以下代码:
marka <-c("Skoda","Skoda","Opel","Volkswagen","Toyota","Toyota","Ford","Dacia","Skoda","Volkswagen","Nissan","Renault","Hyundai","Fiat","Skoda","Toyota","Toyota","Volkswagen","Dacia","Opel","Kia","SEAT","Kia","Renault","Volkswagen","Toyota","Ford","Hyundai","Volvo","Toyota")
model <- c("Octavia","Fabia","Astra","Golf","Yaris","Auris","Focus","Duster","Rapid","Passat","Qashqai","Clio","Tucson","Tipo","Superb","Corolla","C-HR","Tiguan","Sandero","Corsa","Sportage","Leon","Ceed","Megane","Polo","RAV4","Fiesta","i20","XC60","Aygo")
dfall <- data.frame(marka,model)
xyplot(model~marka,data=dfall)制造出这样的东西:

但我正面临着这样的错误:
Warning messages:
1: In order(as.numeric(x)) : NAs introduced by coercion
2: In diff(as.numeric(x[ord])) : NAs introduced by coercion
3: In diff(as.numeric(y[ord])) : NAs introduced by coercion
4: In (function (x, y, type = "p", groups = NULL, pch = if (is.null(groups)) plot.symbol$pch else superpose.symbol$pch, :
NAs introduced by coercion
5: In (function (x, y, type = "p", groups = NULL, pch = if (is.null(groups)) plot.symbol$pch else superpose.symbol$pch, :
NAs introduced by coercion我怎么才能摆脱这个?
发布于 2022-10-26 20:55:39
对于其他可能遇到同样问题的人:
正如Ben在注释中解释的那样,将参数stringsAsFactors设置为TRUE就足够了,因此向量就是因子。
dfall <- data.frame(marka,model, stringsAsFactors = TRUE)https://stackoverflow.com/questions/65108848
复制相似问题