标题不同时如何创建绘图功能?
How to create a plot function when the title differ?
我想制作一张法国地图,让不同的点出现在不同的地图上。
代码很容易做到:
library(raster)
#mydata
pointA <- data.frame(longitude = c(5.819472,5.384418 ),
latitude = c(46.11558, 46.18197))
pointC <- data.frame (longitude = 4.218322,
latitude = 44.20379)
cartes <- function(point){
france <- getData('GADM', country = 'FRA', level = 1) # Map of France
plot(france, border = "red", main = "Name of the point")
points(point$longitude, point$latitude)
}
cartes(pointA)
cartes(pointC)
但是我找不到根据点名更改标题的方法...
你知道怎么做吗?
使用 ensym()
可能会对您有所帮助 :
library(raster)
#mydata
pointA <- data.frame(longitude = c(5.819472,5.384418 ),
latitude = c(46.11558, 46.18197))
pointC <- data.frame (longitude = 4.218322,
latitude = 44.20379)
cartes <- function(point){
france <- getData('GADM', country = 'FRA', level = 1) # Map of France
plot(france, border = "red", main = ensym(point))
points(point$longitude, point$latitude)
}
cartes(pointA)
cartes(pointC)
我想制作一张法国地图,让不同的点出现在不同的地图上。
代码很容易做到:
library(raster)
#mydata
pointA <- data.frame(longitude = c(5.819472,5.384418 ),
latitude = c(46.11558, 46.18197))
pointC <- data.frame (longitude = 4.218322,
latitude = 44.20379)
cartes <- function(point){
france <- getData('GADM', country = 'FRA', level = 1) # Map of France
plot(france, border = "red", main = "Name of the point")
points(point$longitude, point$latitude)
}
cartes(pointA)
cartes(pointC)
但是我找不到根据点名更改标题的方法...
你知道怎么做吗?
使用 ensym()
可能会对您有所帮助 :
library(raster)
#mydata
pointA <- data.frame(longitude = c(5.819472,5.384418 ),
latitude = c(46.11558, 46.18197))
pointC <- data.frame (longitude = 4.218322,
latitude = 44.20379)
cartes <- function(point){
france <- getData('GADM', country = 'FRA', level = 1) # Map of France
plot(france, border = "red", main = ensym(point))
points(point$longitude, point$latitude)
}
cartes(pointA)
cartes(pointC)