getNearestCRAN | R Documentation |
This function computes the distance from a particular IP address/machine to the CRAN servers around the world. We can then use this to determine which server is closest or order the servers by proximity.
getNearestCRAN(ip = getHostIP(), mirrors = getCRANmirrors(),
db = GeoIP_open(GeoIPData, GEOIP_STANDARD),
serverLocations = getMirrorCoordinates(mirrors, db),
byDist = FALSE)
ip |
the name or IP address of the machine of interest. By default, we use the current machine by querying its IP address via a Web site |
mirrors |
a data frame giving the information about the mirrors |
db |
a reference to the the GeoIP database |
serverLocations |
the locations of the CRAN mirrors of interest. This is a 2 x n matrix of longitude and latitude values |
byDist |
a logical value that controls whether to return the URL of the single closest CRAN server, or to return all of the servers ranked by proximity. |
This uses the GeoIP lite database to find the locations of the CRAN mirror servers.
If byDist
is FALSE
, a character vector
of length 1 giving the URL of the nearest server. The name
of the single element is the description of the host, e.g.
"University of California, Berkeley, CA".
If byDist
is TRUE
, the function returns a data frame
containing all the information about the mirrors, ordered by closest
server. So the first observation is the closest server this machine on
which the command was run.
Duncan Temple Lang
GeoIP database from maxmind.com
GeoIP_record_by_addr
and GeoIP_record_by_name
# this is a snapshot of the mirrors taken as an example.
data(oldMirrors)
getNearestCRAN( mirrors = oldMirrors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.