我想在R中绘制一系列坐标(我刚刚开始了解这些坐标),并发现xy.coords是这样做的工具。但是,xy.coords无法正确地解释我想要提供给它的数据。
我用数据导入csv文件
> objectname <- read.csv("./file", header=TRUE, sep=",")直接显示由此产生的数据如下所示:
> chances1617$location_y
[1] - 33.0 76.0 44.0 42.0
[6] 20.0 54.0 16.0 67.0 42.0
[11] 16.0 44.0 31.0 17.0 90.0
[16] 27.0 123.0 28.0 121.0 1.0
...
> chances1617$location_x
[1] - 33.0 -36.0 -12.0
[5] 22.0 2.0 -22.0 -16.0
[9] -21.0 11.0 2.0 0.0
[13] 32.0 -7.0 81.0 -17.0
[17] -89.0 9.0 92.0 -136.0
...而xy.coords将此理解为
> xy.coords(chances1617$location_x, chances1617$location_y)
$y
[1] 1 122 189 142 139 90 157 73 176 139 73 142 119 77 211 109 35 112
[19] 33 3 211 150 73 85 6 140 189 196 140 202 168 122 147 22 150 150
...
$x
[1] 1 235 73 16 218 211 41 27 39 184 211 169 233 135 333 29 158 343
[19] 346 23 31 204 192 33 297 227 126 58 202 4 78 235 26 330 199 192哪里可能出了什么问题?我想用xz.coords以错误的格式处理数据,还是我使用错误的数据,还是它是错误的工具?
发布于 2017-10-26 13:41:25
看起来,您的数据chances1617$location_x和chances1617$location_y都是因素。尝试通过以下方法将它们转换为数字数据。
xy.coords(as.numeric(as.character(chances1617$location_x)),
as.numeric(as.character(chances1617$location_y)))https://stackoverflow.com/questions/46955857
复制相似问题