使用 R Studio 的悬停散点图
Hover-over scatterplot using R Studio
我有一个 R 程序,想要一种将鼠标悬停在数据点上并显示信息的方法。我一直在尝试使用传单,但它太复杂了。 No matter what I try, OpenStreetMap doesn't load in R Studio.
我只是在寻找允许人们将鼠标悬停在数据点上以查看信息的简单方法。此代码显示下图:
library(ggmap)
library(ggplot2)
...
# create a new grouping variable
sep$Percent_SEP12_Assets <- ifelse(sep[,8] <= 33, "Less than 33%", ifelse(sep[,8] >= 66, "More than 66%", "Between 33% and 66%"))
sep$Percent_SEP12_Assets <- factor(sep$Percent_SEP12_Assets,
levels = c("More than 66%", "Between 33% and 66%", "Less than 33%"))
# get the map
bbox <- make_bbox(sep$Longitude, sep$Latitude, f = 1)
map <- get_map(bbox)
# plot the map and use the grouping variable for the fill inside the aes
ggmap(map) +
geom_point(data=sep, aes(x = Longitude, y = Latitude, color=sep$Percent_SEP12_Assets ), size=9, alpha=0.6) +
scale_color_manual(values=c("green","orange","red"), drop = FALSE)
我有一个 R 程序,想要一种将鼠标悬停在数据点上并显示信息的方法。我一直在尝试使用传单,但它太复杂了。 No matter what I try, OpenStreetMap doesn't load in R Studio.
我只是在寻找允许人们将鼠标悬停在数据点上以查看信息的简单方法。此代码显示下图:
library(ggmap)
library(ggplot2)
...
# create a new grouping variable
sep$Percent_SEP12_Assets <- ifelse(sep[,8] <= 33, "Less than 33%", ifelse(sep[,8] >= 66, "More than 66%", "Between 33% and 66%"))
sep$Percent_SEP12_Assets <- factor(sep$Percent_SEP12_Assets,
levels = c("More than 66%", "Between 33% and 66%", "Less than 33%"))
# get the map
bbox <- make_bbox(sep$Longitude, sep$Latitude, f = 1)
map <- get_map(bbox)
# plot the map and use the grouping variable for the fill inside the aes
ggmap(map) +
geom_point(data=sep, aes(x = Longitude, y = Latitude, color=sep$Percent_SEP12_Assets ), size=9, alpha=0.6) +
scale_color_manual(values=c("green","orange","red"), drop = FALSE)