【问题标题】:R ggmap ggplot2 error “Error: Discrete value supplied to continuous scale”R ggmap ggplot2 错误“错误:提供给连续比例的离散值”
【发布时间】:2018-06-20 09:11:57
【问题描述】:

我正在尝试在印度地图上标记印度的机场。我的代码如下:

library(ggmap)

library(ggplot2)

airports <- read.csv("C://Users//MEJA03514//Downloads//in-airports.csv", header=T)

map <- get_googlemap("India", zoom = 4)

points <- ggmap(map) + geom_point(aes(x = longitude_deg, y = latitude_deg), data = airports, alpha = 0.5)

points

我从https://data.humdata.org/dataset/ourairports-ind下载了机场数据文件

我收到一个错误:

错误:提供给连续刻度的离散值

在我将ggmap()geom_point() 函数结合后。你能帮我弄清楚这段代码中的错误是什么吗?

提前致谢!

【问题讨论】:

  • 检查纬度和经度是否存储为数字而不是factor

标签: r csv ggplot2 ggmap


【解决方案1】:

你的代码对我来说很完美。但我也能够重现您的错误:使用View(airport)head(airport) 查看airport,您会注意到您的数据在第一行中有解释变量的值(HXL 标签)。确保您下载没有这些标签的数据或手动删除它们(但您必须正确获取数据类型)。如果勾选str(airport),则经纬度应为numeric,而不是character

【讨论】:

    猜你喜欢
    • 2015-11-09
    • 1970-01-01
    • 2014-11-14
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2016-07-26
    • 2014-07-06
    相关资源
    最近更新 更多