Description Usage Arguments Details Value Author(s) Examples
This function works as a wrapper of the leaflet
function, creating a
map with circles which sizes are set by the number of observations in those
coordinates.
1 2 3 |
dat |
A twitter dataset (with coordinates) |
coordinates |
Name of the |
popup |
Name of the grouping variable (for example, |
lat |
Name of the latitude variable |
lng |
Name of the longitude variable |
radii |
Formula to compute the radious of the circles |
weight |
Thickness of the circles' borders |
cluster.method |
Clustering method (see |
nclusters |
Max number of clusters to include |
... |
Further arguments to be passed to |
The coordinates
must be in the format of longitude:latitude
(as the twitter API returns).
In order to improve visualization, the function performs Hierarchical
Clustering via hclust()
(from the stats package), grouping
observations by geo coordinates. For each cluster, the final lat/lng coords
are defined as the mean within the cluster.
In the case of radii
, it is measured in meters (in the map). The
n
is the number of observations in that cluster.
For performance considerations, it is recommended not to use more than
1,000 observations (Try using a random sample from your data!) as
hclust
requires computing square matrices.
A map object (see the leaflet()
package)
George G. Vega Yon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Not run:
# Getting the data
data(senate_tweets)
# using formulas to pass the variables names
tw_leaflet(senate_tweets,~coordinates,~screen_name)
tw_leaflet(senate_tweets,~coordinates)
# Using characters to pass the variables names
tw_leaflet(senate_tweets,'coordinates','screen_name')
tw_leaflet(senate_tweets,'coordinates')
# Aggregating until get only 3 big groups
tw_leaflet(senate_tweets,'coordinates', nclusters=3)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.