【问题标题】:ERROR: longer object length is not a multiple of shorter object length错误:较长的对象长度不是较短对象长度的倍数
【发布时间】:2015-07-16 13:40:16
【问题描述】:

我有一个数据集,其中包含英国不同地方的多个经度和纬度。我正在尝试使用那些计算在地图上创建多个饼图。最重要的是在地图上制作一个饼图。注意:如果我硬编码纬度和经度,我可以制作一个饼图。

代码:

floating.pie(xpos = area$longditude,  ypos = area$Latitude,x=1,  radius=0.2, col="orange")

地区:

area <- sqlQuery(con, "SELECT top 3 geo.Latitude, geo.longditude FROM dbo.[Geography]")

数据集是:

55.9500, 3.1833
54.8659, -2.3522
54.0167, 2.6333
53.5667, 1.2000
52.8311, 1.3278
52.5000, 1.8333
52.3555, -1.1743
51.5000, 51.5000
51.4833, 3.1833
51.3167, 0.5000
50.9600, -3.2200

我得到的错误是:

Warning messages:
1: In cos(t2p) * radius + xpos :
longer object length is not a multiple of shorter object length
2: In sin(t2p) * yradius + ypos :
longer object length is not a multiple of shorter object length

注意:使用上述所有代码,我根本没有得到单独的饼图。不知道该怎么做,请帮忙。 作为示例视图 plotting pie graphs on map in ggplot

您在 webpaghe 中看到的是我希望它几乎可以工作的内容,只需要知道如何告诉 R 区分我使用 Area 提供的那些值并将它们正确绘制为单个饼图。

【问题讨论】:

  • 你是不是拼错了longitude? (例如你有area$longditude

标签: r analytics rstudio pie-chart


【解决方案1】:

我能够绘制多个浮动饼图,但我不得不使用臭名昭著的for 循环。

area1<-data.frame(Longitude = c(10,30, 50), 
Latitude = c(5, 25, 50))

plot(0:100,type="n",main="Floating Pie test",xlab="",ylab="",axes=FALSE)
for(i in 1:length(area1$Longitude)){
    floating.pie(xpos = area1$Longitude[i],  
    ypos = area1$Latitude[i],edges = 200, x=1,  radius=10, col="orange")
}

【讨论】:

  • 只想指出xposypos 值是绘图区域的坐标,因此您可能必须将坐标值转换为转换为地图的坐标值。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-14
  • 1970-01-01
  • 2020-07-15
  • 2020-07-03
  • 1970-01-01
相关资源
最近更新 更多