Package leaflet.minicharts

Similar documents
Package canvasxpress

Package datasets.load

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package fastdummies. January 8, 2018

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package opencage. January 16, 2018

Package ECctmc. May 1, 2018

Package tiler. June 9, 2018

Package knitrprogressbar

Package slickr. March 6, 2018

Package d3plus. September 25, 2017

Package jpmesh. December 4, 2017

Package shinyfeedback

Package mapedit. R topics documented: March 2, Title Interactive Editing of Spatial Data in R

Package validara. October 19, 2017

Package bisect. April 16, 2018

Package spark. July 21, 2017

Package SEMrushR. November 3, 2018

Package htmlwidgets. July 10, 2017

Package processanimater

Package nlgeocoder. October 8, 2018

Package mapsapi. March 12, 2018

Package docxtools. July 6, 2018

Package projector. February 27, 2018

Package lumberjack. R topics documented: July 20, 2018

Package jstree. October 24, 2017

Package qualmap. R topics documented: September 12, Type Package

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package reconstructr

Package robotstxt. November 12, 2017

Package nngeo. September 29, 2018

Package editdata. October 7, 2017

Package crossword.r. January 19, 2018

Package collapsibletree

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package comparedf. February 11, 2019

Package scatterd3. March 10, 2018

Package rsppfp. November 20, 2018

Package WordR. September 7, 2017

Package shinyaframe. November 26, 2017

Package tidyselect. October 11, 2018

Package profvis. R topics documented:

Package messaging. May 27, 2018

Package barcoder. October 26, 2018

Package htmlwidgets. February 25, 2016

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package linkspotter. July 22, Type Package

Package climber. R topics documented:

Package IATScore. January 10, 2018

Package calpassapi. August 25, 2018

Package d3heatmap. February 1, 2018

Package tibble. August 22, 2017

Package rmapzen. October 7, 2018

Package pmatch. October 19, 2018

Package rgho. R topics documented: January 18, 2017

Package vinereg. August 10, 2018

Package explor. R topics documented: October 10, Type Package Title Interactive Interfaces for Results Exploration Version 0.3.

Package gifti. February 1, 2018

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package dkanr. July 12, 2018

Package githubinstall

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package readxl. April 18, 2017

Package effectr. January 17, 2018

Package epitab. July 4, 2018

Package guardianapi. February 3, 2019

Package wrswor. R topics documented: February 2, Type Package

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package fitbitscraper

Package datapasta. January 24, 2018

Package embed. November 19, 2018

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package shiny.semantic

Package gtrendsr. October 19, 2017

Package semver. January 6, 2017

Package tidytransit. March 4, 2019

Package splithalf. March 17, 2018

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package widyr. August 14, 2017

Package clipr. June 23, 2018

Package weco. May 4, 2018

Package texpreview. August 15, 2018

Package omu. August 2, 2018

Package sfdct. August 29, 2017

Package sigmanet. April 23, 2018

Package zoomgrid. January 3, 2019

Package kirby21.base

Package fingertipsr. May 25, Type Package Version Title Fingertips Data for Public Health

Package timechange. April 26, 2018

Package condformat. October 19, 2017

Package gtrendsr. August 4, 2018

Package data.world. April 5, 2018

Package radix. September 17, 2018

Package modmarg. R topics documented:

Package virustotal. May 1, 2017

Package GFD. January 4, 2018

Package rzeit2. January 7, 2019

Package tidyimpute. March 5, 2018

Package edfreader. R topics documented: May 21, 2017

Package keyholder. May 19, 2018

Transcription:

Type Package Title Mini Charts for Interactive Maps Version 0.5.2 Package leaflet.minicharts December 6, 2017 Add and modify small charts on an interactive map created with package 'leaflet'. These charts can be used to represent at same time multiple variables on a single map. License GPL (>= 2) file LICENSE Depends R (>= 2.10) Imports leaflet (>= 1.1.0), htmltools Encoding UTF-8 LazyData true RoxygenNote 6.0.1 Suggests knitr, rmarkdown, dplyr, shiny, manipulatewidget, testthat, covr VignetteBuilder knitr NeedsCompilation no Author Jalal-Edine ZAWAM [aut, cre], Francois Guillem [aut], RTE [cph] Maintainer Jalal-Edine ZAWAM <jalal-edine.zawam@rte-france.com> Repository CRAN Date/Publication 2017-12-06 16:11:36 UTC R topics documented: addflows.......................................... 2 addminicharts........................................ 3 d3.schemecategory10.................................... 6 eco2mix........................................... 7 popupargs.......................................... 8 syncwith.......................................... 8 1

2 addflows Index 10 addflows Add or modify flows on a leaflet map These functions can be used to represent flows and their evolution on a map created with leaflet(). Flows are simply represented by a segment between two points with an arrow at its center that indicates the direction of the flow. addflows(map, lng0, lat0, lng1, lat1, color = "blue", flow = 1, opacity = 1, dir = NULL, time = NULL, popup = popupargs(labels = "Flow"), layerid = NULL, timeformat = NULL, initialtime = NULL, maxflow = max(abs(flow)), minthickness = 1, maxthickness = 20) updateflows(map, layerid, color = NULL, flow = NULL, opacity = NULL, dir = NULL, time = NULL, popup = NULL, timeformat = NULL, initialtime = NULL, maxflow = NULL, minthickness = 1, maxthickness = 20) removeflows(map, layerid) clearflows(map) Arguments map lng0 lat0 lng1 lat1 color flow opacity dir time A leaflet map object created with leaflet. Longitude of the origin of the flow. Lattitude of the origin of the flow. Longitude of the destination of the flow. Lattitude of the destination of the flow. Color of the flow. Value of the flow between the origin and the destination. If argument dir is not set, negative values are interpreted as flows from destination to origin. Opacity of the flow. Direction of the flow. 1 indicates that the flow goes from origin to destination and -1 indicates that it goes from destination to origin. If 0, the arrow is not drawn. If NULL, then it is equal to the sign of weight. A vector with length equal to the number of rows in chartdata and containing either numbers representing time indices or dates or datetimes. Each unique value must appear as many times as the others. This parameter can be used when one wants to represent the evolution of some variables on a map.

addminicharts 3 popup Options that control popup generation. layerid An ID variable. It is mandatoy when one wants to update some chart with updateminicharts. timeformat initialtime maxflow minthickness maxthickness Character string used to format dates and times when argument time is a Date, POSIXct or POSIXlt object. See strptime for more information. This argument can be used to set the initial time step shown when the map is created. It is used only when argument time is set. Maximal value a flow could take. minimal thickness of the line that represents the flow. maximal thickness of the line that represents the flow. Value The modified leaflet map object. Examples require(leaflet) # Toy example leaflet() %>% addtiles() %>% addflows(0, 0, 1, 1, flow = 10) # Electric exchanges between France and neighbouring countries data("eco2mixbalance") bal <- eco2mixbalance leaflet() %>% addtiles() %>% addflows( bal$lng0, bal$lat0, bal$lng1, bal$lat1, flow = bal$balance, time = bal$month ) addminicharts Add or update charts on a leaflet map these functions add or update minicharts in a leaflet map at given coordinates: they can be bar charts, pie charts or polar charts where chartdata is encoded either by area or by radius.

4 addminicharts addminicharts(map, lng, lat, chartdata = 1, time = NULL, maxvalues = NULL, type = "auto", fillcolor = d3.schemecategory10[1], colorpalette = d3.schemecategory10, width = 30, height = 30, opacity = 1, showlabels = FALSE, labeltext = NULL, labelminsize = 8, labelmaxsize = 24, labelstyle = NULL, transitiontime = 750, popup = popupargs(), layerid = NULL, legend = TRUE, legendposition = "topright", timeformat = NULL, initialtime = NULL, onchange = NULL) updateminicharts(map, layerid, chartdata = NULL, time = NULL, maxvalues = NULL, type = NULL, fillcolor = NULL, colorpalette = d3.schemecategory10, width = NULL, height = NULL, opacity = NULL, showlabels = NULL, labeltext = NULL, labelminsize = NULL, labelmaxsize = NULL, labelstyle = NULL, transitiontime = NULL, popup = NULL, legend = TRUE, legendposition = NULL, timeformat = NULL, initialtime = NULL, onchange = NULL) removeminicharts(map, layerid) clearminicharts(map) Arguments map lng lat chartdata time maxvalues type fillcolor A leaflet map object created with leaflet. Longitude where to place the charts. Lattitude where to place the charts. A numeric matrix with number of rows equal to the number of elements in lng or lat and number of column equal to the number of variables to represent. If parameter time is set, the number of rows must be equal to the length of lng times the number of unique time steps in the data. A vector with length equal to the number of rows in chartdata and containing either numbers representing time indices or dates or datetimes. Each unique value must appear as many times as the others. This parameter can be used when one wants to represent the evolution of some variables on a map. maximal absolute values of the variables to represent. It can be a vector with one value per column of chartdata or a single value. Using a single value enforces charts to use a unique scale for all variables. If it is NULL, the maximum value of chartdata is used. Type of chart. Possible values are "bar" for bar charts, "pie" for pie charts, "polar-area" and "polar-radius" for polar area charts where the values are represented respectively by the area or the radius of the slices. Finally it can be equal to "auto", the default. In this case, if there is only one variable to represent, the chart will be a single circle, else it is a barchart. Used only if data contains only one column. It is the color used to fill the circles.

addminicharts 5 Details colorpalette width height opacity showlabels labeltext labelminsize labelmaxsize labelstyle Color palette to use when chartdata contains more than one column. maximal width of the created elements. maximal height of the created elements. Opacity of the chart. Should values be displayed above chart elements. character vector containing the text content of the charts. Used only if chartdata contains only one column. Minimal height of labels in pixels. When there is not enough space for labels, they are hidden. Maximal height of labels in pixels. Character string containing CSS properties to apply to the labels. transitiontime Duration in milliseconds of the transitions when a property of a chart is updated. popup Options that control popup generation. layerid An ID variable. It is mandatoy when one wants to update some chart with updateminicharts. legend If TRUE and if data has column names, then a legend is automatically added to the map. legendposition Where should legend be placed? timeformat initialtime onchange Character string used to format dates and times when argument time is a Date, POSIXct or POSIXlt object. See strptime for more information. This argument can be used to set the initial time step shown when the map is created. It is used only when argument time is set. (For power users who know javascript) A character string containing javascript code that is exexuted each time a chart is updated. See the details section to understand why and how to use this parameter. Since version 0.5, the parameter onchange can be used to execute some arbitrary javascript code each time a chart is updated (with updateminicharts() or when time step changes). A typical use case would be to change the color of a polygon added with addpolygons based on the data of the chart. It is even possible to create an invisible chart and use it to manage the color and the popup of a polygon. Here is a sample code that do that: leaflet() %>% addtiles() %>% addpolygons(data = mypolygons, layerid = mypolygons$myids) %>% addminicharts( mydata$lon, mydata$lat, time = mydata^time fillcolor = mydata$color, layerid = mydata$myids, width = 0, height = 0, onchange = " var s = this._map.layermanager.getlayer("shape", this.layerid);

6 d3.schemecategory10 ) s.bindpopup(popup); if (opts.fillcolor) { d3.select(s._path).transition().duration(750).attr("fill", opts.fillcolor); }" Value The following objects are available when executing the javascript code: this The current minichart object. See https://rte-antares-rpackage.github.io/leaflet. minichart/-_l.minichart_.html for more information. opts The current options passed to the current minichart object. popup Popup html. d3 The D3 module. Here is a toy example The modified leaflet map object. addminicharts add new minicharts to the map. updateminicharts updates minicharts that have already been added to the map. removeminicharts removes some specific charts from the map and clearminicharts removes all charts from the map and if necessary the legend that has been automatically created. Examples require(leaflet) mymap <- leaflet() %>% addtiles() %>% addminicharts(0, 0, chartdata = 1:3, layerid = "c1") mymap mymap %>% updateminicharts("c1", maxvalues = 6) mymap %>% updateminicharts("c1", type="pie") d3.schemecategory10 d3 color palette A character vector containing ten colors. These colors are used as the default color palette d3.schemecategory10

eco2mix 7 Format An object of class character of length 10. Author(s) Francois Guillem <francois.guillem@rte-france.com> References https://github.com/d3/d3-scale eco2mix Electric production, consumption and exchanges of France eco2mix contains the electric production, consumption and exchanges of France from january 2010 to february 2017 and of 12 french regions from january 2013 to february 2017. In addition to the total production, the table contains one column for each type of production. The table also contains the lattitude and longitude of the center of the regions. eco2mixbalance is an extract of eco2mix that contains only exchanges between France and neighbouring countries, in a convenient format to represent flows on a map. eco2mix eco2mixbalance Format An object of class data.frame with 686 rows and 22 columns. Author(s) Francois Guillem <francois.guillem@rte-france.com> References http://www.rte-france.com/fr/eco2mix/eco2mix

8 syncwith popupargs Options for popup generation This function simply returns a list of options to control the generation of popups. popupargs(showtitle = TRUE, showvalues = TRUE, labels = NULL, supvalues = NULL, suplabels = colnames(supvalues), html = NULL, nopopup = FALSE, digits = NULL) Arguments showtitle showvalues labels supvalues suplabels html nopopup digits If TRUE layer id is displayed as title of popups. If TRUE, values are displayed in popups Names of values. If NULL, column names of the data bound to a chart are used. A data.frame containing additional values to display in popups. Names of the additional values. Character vector containing custom html code for popups. You can use this parameter when you are not happy with the default popups. If TRUE, popups are not created. Max number of decimal digits to display for numeric values. If NULL, all digits are displayed. Value List containing options for popup generation syncwith Synchronize multiple maps This function can be used when multiple leaflet maps are displayed on the same view (for instance in a shiny application or a Rmarkdown document) and one wants to synchronize their center, zoom and time. syncwith() can also be used with basic leaflet maps to synchronize only their zoom and center. syncwith(map, groupname)

syncwith 9 Arguments map groupname A leaflet map object created with leaflet. Character string. All maps that use the same group name will be synchronized. Value The modified leaflet map object. Examples if (require(manipulatewidget) & require(leaflet)) { } # Synchronize zoom and center of basic maps. basicmap1 <- leaflet() %>% addtiles() %>% syncwith("basicmaps") basicmap2 <- leaflet() %>% addtiles() %>% syncwith("basicmaps") combinewidgets(basicmap1, basicmap2) # Synchronize time step of two maps that represent the evolution of some # variable. map1 <- leaflet() %>% addtiles() %>% addminicharts(0, 40, chartdata = 1:10, time = 1:10) %>% syncwith("maps") map2 <- leaflet() %>% addtiles() %>% addminicharts(0, 40, chartdata = 10:1, time = 1:10) %>% syncwith("maps") combinewidgets(map1, map2)

Index Topic datasets d3.schemecategory10, 6 eco2mix, 7 addflows, 2 addminicharts, 3 addpolygons, 5 clearflows (addflows), 2 clearminicharts (addminicharts), 3 d3.schemecategory10, 6 eco2mix, 7 eco2mixbalance (eco2mix), 7 leaflet, 2, 4, 9 popupargs, 8 removeflows (addflows), 2 removeminicharts (addminicharts), 3 strptime, 3, 5 syncwith, 8 updateflows (addflows), 2 updateminicharts (addminicharts), 3 10