[英]plotting coordinates in r with xy.coords
I want to plot a series of coordinates in R (which I am just beginning to learn about) and found xy.coords as a tool to do so. 我想在R中绘制一系列坐标(我才刚刚开始学习),并找到xy.coords作为实现此目的的工具。 however, xy.coords fails to correctly interpret the data I want to feed to it.
但是,xy.coords无法正确解释我要提供给它的数据。
i imported the csv file with the data with 我用数据导入了csv文件
> objectname <- read.csv("./file", header=TRUE, sep=",")
showing the data in resulting from that directly looks like: 直接显示由此产生的数据看起来像:
> 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
...
whereas xy.coords understands this as 而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
What may be going wrong there? 那里可能出了什么问题? Is the data I want to process with xz.coords in a wrong format, or am i using it wrong, or is it the wrong tool?
我要使用xz.coords处理的数据格式错误,还是我使用的数据错误,还是工具错误?
It looks like your data chances1617$location_x
and chances1617$location_y
are factors. 看来您的数据
chances1617$location_x
和chances1617$location_y
是因素。 Try converting them to numeric data by eg 尝试通过例如将它们转换为数字数据
xy.coords(as.numeric(as.character(chances1617$location_x)),
as.numeric(as.character(chances1617$location_y)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.