The two files provided in this directory automatically builds an interactive map from a text file with the addresses of FAANG members:
createFAANGmap.Ris an executable R script (usable on Unix-like OS);
createFAANGmap-sourcing.Rhas to be run from inside R.
See Section Usage for details.
The scripts proceed as follow:
They import the addresses and (optionally) the file which contains previously processed data (as saved by a previous run of the script);
For the new institutes, they query Google (first by entire address, then by city and country and finally by country - this last step is performed with OpenStreetMap) to obtain city | country | latitude | longitude. This step can take a while if a large number of new members have to be searched: to avoid reject of the query by Google, the script includes a delay between each query and is run until all queries have been answered by Google. It is therefore essential that the current data are saved to avoid unnecessary queries. Note: The first file has been processed in about 10 minutes.
The old data are updated with new members (former members that do not exist in the current file are removed) and exported as a text file;
The map is created with leaflet and saved as an HTML file.
The scripts have several arguments (which have to be directly modified in the
createFAANGmap-sourcing.R and are passed as arguments when
running the script for
createFAANGmap.R as described in section "Usage"):
partner_fileare the arguments for the name of the file with all the current partners;
former_file(optional) are the arguments for the name of the file which contains previously processed data;
res_fileare the arguments for the name of the file where to export (text format) the processed data with current partners;
map_fileare the arguments for the name of the file where to save (html format) the interactive map.
The file requires at least a proper R
installation, as well as pandoc and the following R
packages: RJSONIO, leaflet, htmlwidgets, htmltools, optparse (optparse is not
On Linux Ubuntu R can be installed as described in the first two boxes of this page and pandoc is simply installed with
sudo apt-get install pandoc
For every OS, the packages are installed by running the following command lines within R:
install.packages(c("RJSONIO","leaflet","htmlwidgets", "htmltools", "optparse"))
This script is a command line script which can be executed on Unix-like OS. It is used with
./createFAANGmap.R -f "members_20151002.csv" -l "logo.png" -o "recordMembers.txt" -r "output.txt" -m "map.html"
Only the first two arguments are mandatory. If you have an error, you can alternatively try
Rscript createFAANGmap.R -f "members_20151002.csv" -l "logo.png" -o "recordMembers.txt" -r "output.txt" -m "map.html"
From inside R set the working directory (function
setwd()) to the
folder in which the script is saved and, after having updated the initialization
part of the script, run:
This solution is prefered if you are using Windows (even though I do not know how certain parts of the script work on Windows, especially the parts related to pandoc).
Notes to improve the scripts
A few improvements could be obtained if:
the original file contained the institution name (the popup could then contain the institution name);
data were directly obtained from the database (R can query very easily MySQL databases for instance). In particular, this would prevent some inconsistencies in the data (some rows did have four commas instead of three because raw addresses themselves contained comma and where not delimited by quotes).
I would adviced using a CRON task to automatically update the map. Its
integration on the website can be made using
A question? Do not hesitate to contact tuxette.