Title: | Interactive Networks, Timelines, Barplots, Galleries with 'D3.js' |
---|---|
Description: | Creates interactive analytic graphs with 'R'. It joins the data analysis power of R and the visualization libraries of JavaScript in one package. The package provides interactive networks, timelines, barplots, image galleries and evolving networks. Graphs are represented as 'D3.js' graphs embedded in a web page ready for its interactive analysis and exploration. |
Authors: | Modesto Escobar [aut, cph, cre]
|
Maintainer: | Modesto Escobar <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 1.1.29 |
Built: | 2025-02-14 16:29:27 UTC |
Source: | https://github.com/modesto-escobar/rd3plot |
Creates interactive analytic graphs with 'R'. It joins the data analysis power of R and the visualization libraries of JavaScript in one package. The package provides interactive networks, timelines, barplots, image galleries and evolving networks. Graphs are represented as D3 graphs embedded in a web page ready for its interactive analysis and exploration
add_tutorial_rd3
adds a tutorial for a gallery.
add_tutorial_rd3(x, image = NULL, description = NULL)
add_tutorial_rd3(x, image = NULL, description = NULL)
x |
object of class |
image |
character vector indicating the image path, header for the tutorial. |
description |
a character string indicating a desription text to insert in the tutorial. |
Object of class gallery_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data("finches") finches$species <- system.file("extdata", finches$species, package="rD3plot") # copy path to the species field gallery <- gallery_rd3(finches, image="species", main="Species in Galapagos Islands", note="Data source: Sanderson (2000)") gallery <- add_tutorial_rd3(gallery, description="Here you can see different finches species in Galapagos islands.") ## Not run: plot(gallery) ## End(Not run)
data("finches") finches$species <- system.file("extdata", finches$species, package="rD3plot") # copy path to the species field gallery <- gallery_rd3(finches, image="species", main="Species in Galapagos Islands", note="Data source: Sanderson (2000)") gallery <- add_tutorial_rd3(gallery, description="Here you can see different finches species in Galapagos islands.") ## Not run: plot(gallery) ## End(Not run)
barplot_rd3
produces an interactive barplot of coincidences between events.
barplot_rd3(events, links, name = NULL, select = NULL, source = NULL, target = NULL, label = NULL, text = NULL, color = NULL, incidences = NULL, coincidences = NULL, expected = NULL, confidence = NULL, level = .95, significance = NULL, sort = NULL, decreasing = FALSE, scalebar = FALSE, defaultColor = "#1f77b4", note = NULL, cex = 1, language = c("en","es","ca"), dir = NULL)
barplot_rd3(events, links, name = NULL, select = NULL, source = NULL, target = NULL, label = NULL, text = NULL, color = NULL, incidences = NULL, coincidences = NULL, expected = NULL, confidence = NULL, level = .95, significance = NULL, sort = NULL, decreasing = FALSE, scalebar = FALSE, defaultColor = "#1f77b4", note = NULL, cex = 1, language = c("en","es","ca"), dir = NULL)
events |
a data frame with at least two columns of event names (by default 1st column) and incidences (2nd column). Columns for each variable can be specified at name and incidences parameters. |
links |
a data frame with at least three columns indicating source event, target event and number of coincidences (in that order). Columns assigned to each variable can be specified at source, target and concidences parameters. |
name |
column name with event names in the events data frame. |
source |
column name with source names in the links data frame. |
target |
column name with target names in the links data frame. |
select |
event name to start the visualization. |
label |
column name with labels in the events data frame. |
text |
column name with html text in the events data frame. |
color |
column name with color variable in the events data frame. |
coincidences |
column nane with coincidences in the links data frame. |
incidences |
column name with incidences in the events data frame. |
expected |
column name with expected coincidences in the links data frame. |
confidence |
column name with confidence interval in the links data frame. |
level |
confidence level |
significance |
column name with significance in the links data frame. |
sort |
column name in the events data frame to order the bars in the graph. |
decreasing |
order the events in a decreasing order. |
scalebar |
bars are represented filling all the screen height. |
defaultColor |
a string giving a valid html color. |
note |
the lower title of the graph. |
cex |
a number giving the amount by which plotting text should be scaled relative to the default. |
language |
a character string indicating the language of the graph (en=english (default); es=spanish; ca=catalan). |
dir |
a character string representing the directory where the web files will be saved. |
Object of class barplot_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data(finches) data(galapagos) barplot <- barplot_rd3(finches, galapagos, select="Certhidea olivacea", note="Data source: Sanderson (2000)") ## Not run: plot(barplot) ## End(Not run)
data(finches) data(galapagos) barplot <- barplot_rd3(finches, galapagos, select="Certhidea olivacea", note="Data source: Sanderson (2000)") ## Not run: plot(barplot) ## End(Not run)
evolNetwork_rd3
produce an evolving network.
evolNetwork_rd3(..., timelinks = NULL, timenodes = NULL, timestart = NULL, timeend = NULL, frame = 0, speed = 50, loop = FALSE, lineplots = NULL, dir = NULL)
evolNetwork_rd3(..., timelinks = NULL, timenodes = NULL, timestart = NULL, timeend = NULL, frame = 0, speed = 50, loop = FALSE, lineplots = NULL, dir = NULL)
... |
|
timelinks |
a data frame with at least three columns with source, target and timestart to especify evolutive relations. Only used if |
timenodes |
a data frame with at least two columns with node names and timestart to especify evolutive values in nodes. Only used if |
timestart |
name of the column with the start time of a link in the timelinks data frame. |
timeend |
name of the column with the end time of a link in the timelinks data frame. |
frame |
a frame ordinal position where the playback will start. |
speed |
a percentage value for the playback speed of network frames. |
loop |
allowing continuous repetition. |
lineplots |
a character vector giving the node attributes to show as lineplots. |
dir |
a "character" string representing the directory where the graph will be saved. |
This function returns a network_rd3
object.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
nets <- list() N <- data.frame(name="node1") E <- data.frame() for(i in 2:100){ N <- rbind(N,data.frame(name=paste0("node",i))) E <- rbind(E,data.frame(Source=paste0("node",i-1),Target=paste0("node",i))) nets[[paste0("net",i-1)]] <- network_rd3(N, E, repulsion=100-i, label=FALSE) } net <- evolNetwork_rd3(nets, speed=100) ## Not run: plot(net) ## End(Not run) links <- data.frame() repulsion <- numeric() for(i in 2:100){ links <- rbind(links, data.frame(Source=paste0("node",i-1), Target=paste0("node",i), time=paste0("stage_",i-1))) repulsion <- c(repulsion, 100-i) } net2 <- evolNetwork_rd3(timelinks=links, timestart="time", speed=100, repulsion=repulsion, label=FALSE) ## Not run: plot(net2) ## End(Not run)
nets <- list() N <- data.frame(name="node1") E <- data.frame() for(i in 2:100){ N <- rbind(N,data.frame(name=paste0("node",i))) E <- rbind(E,data.frame(Source=paste0("node",i-1),Target=paste0("node",i))) nets[[paste0("net",i-1)]] <- network_rd3(N, E, repulsion=100-i, label=FALSE) } net <- evolNetwork_rd3(nets, speed=100) ## Not run: plot(net) ## End(Not run) links <- data.frame() repulsion <- numeric() for(i in 2:100){ links <- rbind(links, data.frame(Source=paste0("node",i-1), Target=paste0("node",i), time=paste0("stage_",i-1))) repulsion <- c(repulsion, 100-i) } net2 <- evolNetwork_rd3(timelinks=links, timestart="time", speed=100, repulsion=repulsion, label=FALSE) ## Not run: plot(net2) ## End(Not run)
Data frame with events as result.
data("finches")
data("finches")
A data frame with 13 observations (pinches) and 4 variables (name and characteristics):
name
: Genus and species of the finche
frequency
: number of islands where the finche can be found
type
: Genus of the finche
species
: name of the file containing the picture of the finche
Sanderson, James (2000). Testing Ecological Patterns: A Well-known Algorithm from Computer Science Aids the Evaluation of Species Distributions. American Scientist, 88, pp. 332-339.
data(finches) head(finches,10)
data(finches) head(finches,10)
Data frame containing data of finches coapperance in the Galagos Islands.
data("galapagos")
data("galapagos")
This links data set consists of three variables of length 60:
Source
: Finche 1
Target
: Finche 2
coincidences
: number of islands they share
Sanderson, James (2000). Testing Ecological Patterns: A Well-known Algorithm from Computer Science Aids the Evaluation of Species Distributions. American Scientist, 88, pp. 332-339.
data(galapagos) head(galapagos,10)
data(galapagos) head(galapagos,10)
gallery_rd3
produces an interactive image gallery.
gallery_rd3(nodes, name = NULL, label = NULL, color = NULL, border = NULL, ntext = NULL, info = NULL, infoFrame = c("right","left"), image = NULL, zoom = 1, itemsPerRow = NULL, main = NULL, note = NULL, showLegend = TRUE, frequencies = FALSE, labelTooltip = TRUE, cexTooltip = 1, help = NULL, helpOn = FALSE, tutorial = FALSE, description = NULL, descriptionWidth = NULL, roundedItems = FALSE, ntextctrl = FALSE, controls = 1:5, cex = 1, defaultColor = "#1f77b4", language = c("en", "es", "ca"), dir = NULL)
gallery_rd3(nodes, name = NULL, label = NULL, color = NULL, border = NULL, ntext = NULL, info = NULL, infoFrame = c("right","left"), image = NULL, zoom = 1, itemsPerRow = NULL, main = NULL, note = NULL, showLegend = TRUE, frequencies = FALSE, labelTooltip = TRUE, cexTooltip = 1, help = NULL, helpOn = FALSE, tutorial = FALSE, description = NULL, descriptionWidth = NULL, roundedItems = FALSE, ntextctrl = FALSE, controls = 1:5, cex = 1, defaultColor = "#1f77b4", language = c("en", "es", "ca"), dir = NULL)
nodes |
a data frame with at least one column with the names of the gallery's elements. |
name |
name of the vector with names in the nodes data frame. |
label |
column name with image labels in the nodes data frame. |
color |
column name with image background color variable in the nodes data frame. |
border |
column name with image border width variable in the nodes data frame or a numeric vector. |
ntext |
column name with html text in the nodes data frame. |
info |
column name with information to display in a panel in the nodes data frame. |
infoFrame |
In which panel should the information be displayed? The left panel is only available if frequencies are not showing. |
image |
column name which indicates the image paths in the nodes data frame. |
zoom |
a number between 0.1 and 10 as initial displaying zoom. |
itemsPerRow |
number of items in each row. |
main |
upper title of the graph. |
note |
lower title of the graph. |
frequencies |
a logical value true if barplots representing node attributes frequencies will be added to the final graph. |
labelTooltip |
show label on mouseover. |
cexTooltip |
number indicating the amount by which plotting text should be scaled relative to the default in the label tooltip. |
showLegend |
a logical value true if the legend is to be shown. |
help |
a character string indicating a help text of the graph. |
helpOn |
Should the help be shown at the beginning? |
tutorial |
Should tutorial be displayed? |
description |
a character string indicating a desription text for the graph. |
descriptionWidth |
a percentage indicating a width for the description panel (25 by default). |
roundedItems |
Display items with rounded borders. |
ntextctrl |
Previous tooltips will be closed unless you hold down the control key (FALSE by default). |
controls |
a numeric vector indicating which controls will be shown. 1 = topbar, 2 = xlsx exportation, 3 = table, 4 = netCoin logo, 5 = topbar buttons. NULL hide all controls, negative values deny each control and 0 deny all. |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. |
defaultColor |
a character vector giving a valid html color for node representation. |
language |
a character string indicating the language of the graph (en=english (default); es=spanish; ca=catalan). |
dir |
a character string representing the directory where the web files will be saved. |
Object of class gallery_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data("finches") finches$species <- system.file("extdata", finches$species, package="rD3plot") # copy path to the species field gallery <- gallery_rd3(finches, image="species", main="Species in Galapagos Islands", note="Data source: Sanderson (2000)") ## Not run: plot(gallery) ## End(Not run)
data("finches") finches$species <- system.file("extdata", finches$species, package="rD3plot") # copy path to the species field gallery <- gallery_rd3(finches, image="species", main="Species in Galapagos Islands", note="Data source: Sanderson (2000)") ## Not run: plot(gallery) ## End(Not run)
gallery2_rd3
produces an interactive image gallery (alternative display).
gallery2_rd3(nodes, name = NULL, label = NULL, subtitle = NULL, order = NULL, decreasing = FALSE, ntext = NULL, mainframeHeight = NULL, image = NULL, zoom = NULL, main = NULL, note = NULL, tutorial = FALSE, tableButton = FALSE, export = FALSE, colorScheme = 0, language = c("en", "es", "ca"), dir = NULL)
gallery2_rd3(nodes, name = NULL, label = NULL, subtitle = NULL, order = NULL, decreasing = FALSE, ntext = NULL, mainframeHeight = NULL, image = NULL, zoom = NULL, main = NULL, note = NULL, tutorial = FALSE, tableButton = FALSE, export = FALSE, colorScheme = 0, language = c("en", "es", "ca"), dir = NULL)
nodes |
a data frame with at least one column with the names of the gallery's elements. |
name |
name of the vector with names in the nodes data frame. |
label |
column name with image labels in the nodes data frame. |
subtitle |
column name with image subtitles in the nodes data frame. |
order |
name of the column with node order in the nodes data frame. |
decreasing |
decreasing or increasing sort of the nodes. |
ntext |
column name with html text in the nodes data frame. |
mainframeHeight |
a number between 0.1 and 1 to reduce mainframe height. |
image |
column name which indicates the image paths in the nodes data frame. |
zoom |
a number between 0.1 and 1 to reduce item sizes. |
main |
upper title of the graph. |
note |
lower title of the graph. |
tutorial |
Should tutorial be displayed? |
tableButton |
A button will appear to show the data as a table. |
export |
A button will appear to export gallery as excel. |
colorScheme |
Select a color theme for display (0-11). |
language |
a character string indicating the language of the graph (en=english (default); es=spanish; ca=catalan). |
dir |
a character string representing the directory where the web files will be saved. |
Object of class gallery_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data("finches") finches$species <- system.file("extdata", finches$species, package="rD3plot") # copy path to the species field gallery <- gallery2_rd3(finches, image="species") ## Not run: plot(gallery) ## End(Not run)
data("finches") finches$species <- system.file("extdata", finches$species, package="rD3plot") # copy path to the species field gallery <- gallery2_rd3(finches, image="species") ## Not run: plot(gallery) ## End(Not run)
A list of two datasets, vertices and edges, containing data on characters and their coapperance in chapters in Victor Hugo's Les Miserables.
data("miserables")
data("miserables")
A list of two data frames:
the links data set consists of three variables of length 254:
Source: Character 1
Target: Character 2
value: number of times they appear together in a chapter of Les Miserables
the nodes data set consists of two variables with information on 77 characters:
name: Character name
group: Character group
D. E. Knuth, The Stanford GraphBase: A Platform for Combinatorial Computing, Addison-Wesley, Reading, MA (1993).
data(miserables) head(miserables,10)
data(miserables) head(miserables,10)
network_rd3
produces a network_rd3
object ready for its representation as an interactive network in a web browser. Its input has to be two data.frames: one of attributes of events or nodes, and the other of attributes of the edges or links.
network_rd3(nodes = NULL, links = NULL, tree = NULL, community = NULL, layout = NULL, name = NULL, label = NULL, group = NULL, groupText = FALSE, labelSize = NULL, size = NULL, color = NULL, shape = NULL, border = NULL, legend = NULL, sort = NULL, decreasing = FALSE, ntext = NULL, info = NULL, image = NULL, imageNames = NULL, nodeBipolar = FALSE, nodeFilter = NULL, degreeFilter = NULL, source = NULL, target = NULL, lwidth = NULL, lweight = NULL, lcolor = NULL, ltext = NULL, intensity = NULL, linkBipolar = FALSE, linkFilter = NULL, repulsion = 25, distance = 10, zoom = 1, fixed = showCoordinates, limits = NULL, main = NULL, note = NULL, showCoordinates = FALSE, showArrows = FALSE, showLegend = TRUE, frequencies = FALSE, showAxes = FALSE, axesLabels = NULL, scenarios = NULL, help = NULL, helpOn = FALSE, mode = c("network","heatmap"), roundedItems = FALSE, controls = 1:8, cex = 1, background = NULL, defaultColor = "#1f77b4", language = c("en","es","ca"), dir = NULL)
network_rd3(nodes = NULL, links = NULL, tree = NULL, community = NULL, layout = NULL, name = NULL, label = NULL, group = NULL, groupText = FALSE, labelSize = NULL, size = NULL, color = NULL, shape = NULL, border = NULL, legend = NULL, sort = NULL, decreasing = FALSE, ntext = NULL, info = NULL, image = NULL, imageNames = NULL, nodeBipolar = FALSE, nodeFilter = NULL, degreeFilter = NULL, source = NULL, target = NULL, lwidth = NULL, lweight = NULL, lcolor = NULL, ltext = NULL, intensity = NULL, linkBipolar = FALSE, linkFilter = NULL, repulsion = 25, distance = 10, zoom = 1, fixed = showCoordinates, limits = NULL, main = NULL, note = NULL, showCoordinates = FALSE, showArrows = FALSE, showLegend = TRUE, frequencies = FALSE, showAxes = FALSE, axesLabels = NULL, scenarios = NULL, help = NULL, helpOn = FALSE, mode = c("network","heatmap"), roundedItems = FALSE, controls = 1:8, cex = 1, background = NULL, defaultColor = "#1f77b4", language = c("en","es","ca"), dir = NULL)
nodes |
a data frame with at least one column of node names. |
links |
a data frame with at least two columns with source and target node names. |
tree |
a data frame with two columns: source and target, describing relationships between nodes. It indicates a hierarchy between nodes which can be dynamically explored. |
name |
name of the column with names in the nodes data frame. |
source |
name of the column with source names in the links data frame. |
target |
name of the column with target names in the links data frame. |
label |
name of the column with labels in the nodes data frame. |
group |
name of the column with groups in the nodes data frame. |
groupText |
show names of the groups. |
community |
algorithm to make communities: edge_betweenness("ed"), fast_greedy("fa"), label_prop("la"), leiden_eigen("le"), louvain("lo"), optimal("op"), spinglass("sp"), walktrap("wa") |
labelSize |
name of the column with label size in the nodes data frame. |
size |
name of the column with size in the nodes data frame. |
color |
name of the column with color variable in the nodes data frame. |
shape |
name of the column with shape variable in the nodes data frame. |
legend |
name of the column with the variable to represent as a legend in the nodes data frame. |
ntext |
name of the column with html text in the nodes data frame. |
info |
name of the column with information to display in a panel in the nodes data frame. |
border |
name of the column with border width in the nodes data frame. |
sort |
name of the column with node order in the nodes data frame (only for heatmap). |
decreasing |
decreasing or increasing sort of the nodes (only for heatmap). |
intensity |
name of the column with intensity variable in the links data frame (only for heatmap). |
lwidth |
name of the column with width variable in the links data frame. |
lweight |
name of the column with weight variable in the links data frame. |
lcolor |
name of the column with color variable in the links data frame. |
ltext |
name of the column with labels in the links data frame. |
nodeFilter |
a character string with a condition for filtering nodes. |
linkFilter |
a character string with a condition for filtering links. |
degreeFilter |
numeric vector to filter the resulting network by degree. Input can be a number which specifies the minimum degree or two numbers which specify the lower and upper limits of the filter. |
nodeBipolar |
a logical value that polarizes negative and positive node values in the graphical representation. Indicates whether the color key should be made symmetric about 0. |
linkBipolar |
a logical value that polarizes negative and positive link values in the graphical representation. Indicates whether the color key should be made symmetric about 0. |
defaultColor |
a character vector giving a valid html color for node representation. |
repulsion |
a percentage for repulsion between nodes. |
distance |
a percentage for distance of links. |
zoom |
a number between 0.1 and 10 to start displaying zoom. |
fixed |
prevent nodes from being dragged. |
scenarios |
a note showing number of scenarios. |
main |
upper title of the graph. |
note |
lower title of the graph. |
frequencies |
a logical value true if barplots representing node attributes frequencies will be added to the final graph. |
help |
help text of the graph. |
helpOn |
Should the help be shown at the beginning? |
background |
background color or image path of the graph. |
layout |
a matrix with two columns with x/y coordinates or an algorithm to calculate the static layout of the network: davidson.harel drl("da"), circle("ci"), Force-Atlas-2("fo"), fruchterman.reingold("fr"), gem("ge"), grid("gr"), kamada.kawai("ka"), lgl("lg"), mds("md"), random("ra"), reingold.tilford("re"), star("sta"), sugiyama("sug") |
limits |
vector indicating the layout limits, must be a numeric vector of length 4 on this order: x_min, y_min, x_max, y_max. |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. |
roundedItems |
Display images with rounded borders. |
controls |
a numeric vector indicating which controls will be shown. 1 = sidebar, 2 = selection buttons, 3 = export buttons, 4 = nodes table, 5 = links table, 6 = search, 7 = zoom, 8 = legend. NULL hide all controls, negative values deny each control and 0 deny all. |
mode |
a character vector indicating the graph mode allowed: network, heatmap or both (both by default). |
showCoordinates |
a logical value true if the coordinates are to be shown in tables and axes. Default = FALSE. |
showArrows |
a logical value true if the directional arrows are to be shown. Default = FALSE. |
showLegend |
a logical value true if the legend is to be shown. |
showAxes |
a logical value true if the axes are to be shown. |
axesLabels |
a character vector giving the axes names. |
language |
a character string indicating the language of the graph (en=english (default); es=spanish; ca=catalan). |
image |
name of the column with the path to node image files in the nodes data frame. |
imageNames |
name of the column with names for image files in the nodes data frame which will be shown in the legend. |
dir |
a "character" string representing the directory where the resulting web files will be saved. |
This function returns a network_rd3
object.
If the 'dir' attribute is specified, the function creates a folder in the computer with an HTML document named index.html which contains the produced graph. This file can be directly opened with your browser and sent to a web server to work properly.
nodes and links arguments can be substituted by a network_rd3 object to add or change options to it.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") ## Not run: plot(net) ## End(Not run)
data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") ## Not run: plot(net) ## End(Not run)
pie_rd3
produces an interactive barplot of coincidences between events.
pie_rd3(v, w = NULL, labels = NULL, colors = NULL, nodes = NULL, links = NULL, name = NULL, source = NULL, target = NULL, lcolor = NULL, ablineX = NULL, ablineY = NULL, hideUpper = FALSE, main = NULL, note = NULL, showLegend = TRUE, help = NULL, helpOn = FALSE, cex = 1, language = c("en", "es", "ca"), dir = NULL)
pie_rd3(v, w = NULL, labels = NULL, colors = NULL, nodes = NULL, links = NULL, name = NULL, source = NULL, target = NULL, lcolor = NULL, ablineX = NULL, ablineY = NULL, hideUpper = FALSE, main = NULL, note = NULL, showLegend = TRUE, help = NULL, helpOn = FALSE, cex = 1, language = c("en", "es", "ca"), dir = NULL)
v |
a vector or array of non-negative numerical quantities. The values are displayed as the areas of pie slices. |
w |
an array of non-negative numerical quantities. The first value is displayed as a pie slice bordered red. |
labels |
character strings giving names for the slices. |
colors |
a vector of colors to be used in filling the slices. |
nodes |
a data frame with information for rows and columns. |
links |
a data frame with information for each pie. |
name |
name of the column with rownames and colnames in the nodes data frame. |
source |
name of the column with rownames in the links data frame. |
target |
name of the column with colnames in the links data frame. |
lcolor |
name of the column with color variable in the links data frame. |
ablineX |
adds one or more straight vertical lines between pies. |
ablineY |
adds one or more straight horizontal lines between pies. |
hideUpper |
should hide the upper triangle? |
main |
upper title of the graph. |
note |
lower title of the graph. |
showLegend |
a logical value true if the legend is to be shown. |
help |
a character string indicating a help text of the graph. |
helpOn |
Should the help be shown at the beginning? |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. |
language |
a character vector (es=spanish; en=english; ca=catalan). |
dir |
a character string representing the directory where the web files will be saved. |
Object of class pie_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
pie <- pie_rd3(1:4, labels = c("XY","X","","Y"), colors = c("black","cadetblue2", "white","cadetblue3")) ## Not run: plot(pie) ## End(Not run)
pie <- pie_rd3(1:4, labels = c("XY","X","","Y"), colors = c("black","cadetblue2", "white","cadetblue3")) ## Not run: plot(pie) ## End(Not run)
rd3_addDescription
adds a description to a 'rD3plot' object.
rd3_addDescription(x, description)
rd3_addDescription(x, description)
x |
A 'rD3plot' object. |
description |
the description text. |
A 'rD3plot' object.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") img <- system.file("extdata", "p.Crassirostris.png", package="rD3plot") bar <- rd3_addDescription(bar,"Species coincidences in Galapagos Islands") multi <- rd3_multigraph(barplot=bar) ## Not run: rd3_multiPages(multi,"Graph image example",show=TRUE) ## End(Not run)
data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") img <- system.file("extdata", "p.Crassirostris.png", package="rD3plot") bar <- rd3_addDescription(bar,"Species coincidences in Galapagos Islands") multi <- rd3_multigraph(barplot=bar) ## Not run: rd3_multiPages(multi,"Graph image example",show=TRUE) ## End(Not run)
rd3_addImage
adds an image to a 'rD3plot' object.
rd3_addImage(x, img)
rd3_addImage(x, img)
x |
A 'rD3plot' object. |
img |
character vector indicating the image path. |
A 'rD3plot' object.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") img <- system.file("extdata", "p.Crassirostris.png", package="rD3plot") bar <- rd3_addImage(bar,img) multi <- rd3_multigraph(barplot=bar) ## Not run: rd3_multiPages(multi,"Graph image example",show=TRUE) ## End(Not run)
data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") img <- system.file("extdata", "p.Crassirostris.png", package="rD3plot") bar <- rd3_addImage(bar,img) multi <- rd3_multigraph(barplot=bar) ## Not run: rd3_multiPages(multi,"Graph image example",show=TRUE) ## End(Not run)
rd3_fromIgraph
produce an interactive network from an 'igraph' object.
rd3_fromIgraph(G, ...)
rd3_fromIgraph(G, ...)
G |
an igraph object. |
... |
Any network_rd3 argument. |
This function returns a network_rd3
object.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
g <- igraph::make_ring(10) rd3_fromIgraph(g)
g <- igraph::make_ring(10) rd3_fromIgraph(g)
rd3_layoutCircle
produces a circle layout of any number of nodes.
rd3_layoutCircle(N,nodes=seq_len(nrow(N)),deg=0,name=NULL)
rd3_layoutCircle(N,nodes=seq_len(nrow(N)),deg=0,name=NULL)
N |
a data frame of nodes. |
nodes |
a vector specifing the node names inclued in the layout calculation. |
deg |
rotation degrees. |
name |
column name with node names in the N data frame. |
‘rd3_layoutCircle’ produces a circle layout of any number of nodes.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
A <- data.frame(name=letters) L <- rd3_layoutCircle(A,name="name") net <- network_rd3(A,layout=L) ## Not run: plot(net) ## End(Not run)
A <- data.frame(name=letters) L <- rd3_layoutCircle(A,name="name") net <- network_rd3(A,layout=L) ## Not run: plot(net) ## End(Not run)
rd3_layoutGrid
produces a grid layout of any number of nodes.
rd3_layoutGrid(N,string,name=NULL,byrow=FALSE)
rd3_layoutGrid(N,string,name=NULL,byrow=FALSE)
N |
a data frame of nodes. |
string |
a character vector specifing grouped nodes. |
name |
column name with node names in the N data frame. |
byrow |
order nodes by row (default) or by columns (FALSE) |
‘rd3_layoutGrid’ produces a grid layout of any number of nodes.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
A <- data.frame(name=letters) L <- rd3_layoutGrid(A,"a,b,c,d,e.f,g,h,i,j.k,l,m,n,o,p.q,r,s,t,u.v,w,x,y,z","name") net <- network_rd3(A,layout=L) ## Not run: plot(net) ## End(Not run)
A <- data.frame(name=letters) L <- rd3_layoutGrid(A,"a,b,c,d,e.f,g,h,i,j.k,l,m,n,o,p.q,r,s,t,u.v,w,x,y,z","name") net <- network_rd3(A,layout=L) ## Not run: plot(net) ## End(Not run)
rd3_multigraph
produce an interactive multi graph with the integration of 'rD3plot' graphs in the final result.
rd3_multigraph(..., mfrow = NULL, dir = NULL)
rd3_multigraph(..., mfrow = NULL, dir = NULL)
... |
rD3plot graphs (network_rd3, barplot_rd3, timeplot_rd3) objects or string paths to html "directories". |
mfrow |
a vector of the form 'c(nr, nc)'. Subsequent graphs will be drawn in an 'nr'-by-'nc' array on the device by rows. |
dir |
a "character" string representing the directory where the graph will be saved. |
This function returns a multi_rd3
object.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") data(sociologists) time <- timeline_rd3(sociologists,"name","birth","death","birthcountry") multi <- rd3_multigraph(network=net, barplot=bar, timeline=time) ## Not run: plot(multi) ## End(Not run)
data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") data(sociologists) time <- timeline_rd3(sociologists,"name","birth","death","birthcountry") multi <- rd3_multigraph(network=net, barplot=bar, timeline=time) ## Not run: plot(multi) ## End(Not run)
rd3_multiPages
produces a gallery page to explore multiple 'rD3plot' graphs.
rd3_multiPages(x, title = NULL, columns = NULL, imageSize = NULL, description = NULL, note = NULL, cex = 1, dir = tempDir(), show = FALSE)
rd3_multiPages(x, title = NULL, columns = NULL, imageSize = NULL, description = NULL, note = NULL, cex = 1, dir = tempDir(), show = FALSE)
x |
is a |
title |
the text for a main title. |
columns |
a numeric vector giving the number of columns to display items in gallery. Default = 3. |
imageSize |
a numeric vector giving the size of images in gallery. Default = 75. |
description |
a description text for the gallery. |
note |
a footer text for the gallery. |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. Default = 1. |
dir |
a "character" string representing the directory where the graph will be saved. |
show |
a logical value true if the graph is to be shown. Default = FALSE. |
The function creates a folder in your computer with an HTML document named index.html which contains the graph. This file can be directly opened with your browser.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") data(sociologists) time <- timeline_rd3(sociologists,"name","birth","death","birthcountry") multi <- rd3_multigraph(network=net, barplot=bar, timeline=time) ## Not run: rd3_multiPages(multi,"Some graphs",show=TRUE) ## End(Not run)
data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") data(finches) data(galapagos) bar <- barplot_rd3(finches, galapagos, select="Certhidea olivacea") data(sociologists) time <- timeline_rd3(sociologists,"name","birth","death","birthcountry") multi <- rd3_multigraph(network=net, barplot=bar, timeline=time) ## Not run: rd3_multiPages(multi,"Some graphs",show=TRUE) ## End(Not run)
creates an igraph
object from a network_rd3
object.
rd3_toIgraph(net)
rd3_toIgraph(net)
net |
is a |
An igraph
object.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
# A character column (with separator) data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") rd3_toIgraph(net) # conversion into a igraph object
# A character column (with separator) data(miserables) net <- network_rd3(miserables$nodes, miserables$links, size="degree", color="group", lwidth="value") rd3_toIgraph(net) # conversion into a igraph object
Load a rD3plot graph to display in 'Shiny'.
shiny_rd3(x)
shiny_rd3(x)
x |
is a |
This function returns a shiny.tag
object.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Data frame with names, birth and death year data, birth country and movement.
data("sociologists")
data("sociologists")
A data frame with 33 observations and the following 4 variables (events) to study coincidences in time:
name
: name and last name of the sociologist
birth
: birth year
death
: death year
birthcountry
: birth country
movements
: movement or school of thought
Own elaboration from manuals of sociology.
data(sociologists) head(sociologists, 10) tail(sociologists, 10)
data(sociologists) head(sociologists, 10) tail(sociologists, 10)
timeline_rd3
produces a timeline_rd3
object ready for its representation as an interactive time line in a web browser.
timeline_rd3(periods, name = "name", start = "start", end = "end", group = NULL, text = NULL, main = NULL, note = NULL, info = NULL, events = NULL, eventNames = "name", eventPeriod = "period", eventTime = "date", eventColor = NULL, eventShape = NULL, cex = 1, language = c("en","es","ca"), dir = NULL)
timeline_rd3(periods, name = "name", start = "start", end = "end", group = NULL, text = NULL, main = NULL, note = NULL, info = NULL, events = NULL, eventNames = "name", eventPeriod = "period", eventTime = "date", eventColor = NULL, eventShape = NULL, cex = 1, language = c("en","es","ca"), dir = NULL)
periods |
a data frame with at least three columns describing period names, start and end. |
name |
name of the column with names in the periods data frame. |
start |
name of the column with starts in the periods data frame. |
end |
name of the column with ends in the periods data frame. |
group |
name of the column with a grouping criteria in the periods data frame. |
text |
name of the column with a descriptive text of periods (html format) in the periods data frame. |
main |
upper title of the graph. |
note |
lower title of the graph. |
info |
name of the column in the periods data frame with information to display on the information panel. |
events |
a data frame of events related to periods (shown as dots) with three columns: interval name, event name and event date |
eventNames |
name of the column with event identifiers in the events data frame. |
eventPeriod |
name of the column with interval identifiers in the events data frame. |
eventTime |
name of the column with time points in the events data frame. |
eventColor |
name of the column with the color criteria in the events data frame. |
eventShape |
name of the column with the shape criteria in the events data frame. |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. |
language |
a character string indicating the language of the graph (en=english (default); es=spanish; ca=catalan). |
dir |
a "character" string representing the directory where the web files will be saved. |
Object of class timeline_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
# Database of 19th century sociologists data(sociologists) timeline <- timeline_rd3(sociologists,"name","birth","death","birthcountry") ## Not run: plot(timeline) ## End(Not run)
# Database of 19th century sociologists data(sociologists) timeline <- timeline_rd3(sociologists,"name","birth","death","birthcountry") ## Not run: plot(timeline) ## End(Not run)
treeGallery_rd3
produces an interactive image gallery.
treeGallery_rd3(tree, deep = FALSE, initialType = NULL, tableformat = FALSE, ...)
treeGallery_rd3(tree, deep = FALSE, initialType = NULL, tableformat = FALSE, ...)
tree |
a data frame with two columns: source and target, describing relationships between nodes. It indicates a hierarchy between nodes which can be dynamically explored. Optionally, another two columns describing types can be passed. |
deep |
The tree is especified in a structure that preserves paths. Each column will be a tree level, colnames as node types. |
initialType |
A character vector indicating which node type will be shown at start. No effects in 'deep' mode. |
tableformat |
If the tree is especified as a table, one column per level. No effects in 'deep' mode. |
... |
Any gallery_rd3 argument. |
Object of class treeGallery_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
# simply linked tree tree <- data.frame( parent=c("a","a","b","b","b","ab","ab","ab","ab","ba","ba","baa","ba"), child=c("aa","ab","ba","bb","bc","aba","abb","abc","abd","baa","bab","baaa","aba") ) gallery <- treeGallery_rd3(tree) ## Not run: plot(gallery) ## End(Not run) # Create some film data tree <- data.frame( film = c("The Shawshank Redemption", "The Godfather", "The Dark Knight", "The Godfather Part II", "12 Angry Men", "Schindler's List", "The Lord of the Rings: The Return of the King", "Pulp Fiction", "The Lord of the Rings: The Fellowship of the Ring", "The Good, the Bad and the Ugly"), director = c("Frank Darabont", "Francis Ford Coppola", "Christopher Nolan", "Francis Ford Coppola", "Sidney Lumet", "Steven Spielberg", "Peter Jackson", "Quentin Tarantino", "Peter Jackson", "Sergio Leone"), actor = c("Tim Robbins|Morgan Freeman|Bob Gunton", "Marlon Brando|Al Pacino|James Caan", "Christian Bale|Heath Ledger|Aaron Eckhart", "Al Pacino|Robert De Niro|Robert Duvall", "Henry Fonda|Lee J. Cobb|Martin Balsam", "Liam Neeson|Ralph Fiennes|Ben Kingsley", "Elijah Wood|Viggo Mortensen|Ian McKellen", "John Travolta|Uma Thurman|Samuel L. Jackson", "Elijah Wood|Viggo Mortensen|Ian McKellen", "Clint Eastwood|Eli Wallach|Lee Van Cleef") ) gallery <- treeGallery_rd3(tree, initialType="film", tableformat=TRUE, color="type", zoom=2) ## Not run: plot(gallery) ## End(Not run) # example with path preservation tree <- rbind( c("a1","b1","c1|c2"), c("a2","b2","c3|c4"), c("a3","b2","c4|c5"), c("a4","b3|b4","c6|c7|c8") ) colnames(tree) <- c("a","b","c") gallery <- treeGallery_rd3(tree, deep=TRUE, color="type") ## Not run: plot(gallery) ## End(Not run)
# simply linked tree tree <- data.frame( parent=c("a","a","b","b","b","ab","ab","ab","ab","ba","ba","baa","ba"), child=c("aa","ab","ba","bb","bc","aba","abb","abc","abd","baa","bab","baaa","aba") ) gallery <- treeGallery_rd3(tree) ## Not run: plot(gallery) ## End(Not run) # Create some film data tree <- data.frame( film = c("The Shawshank Redemption", "The Godfather", "The Dark Knight", "The Godfather Part II", "12 Angry Men", "Schindler's List", "The Lord of the Rings: The Return of the King", "Pulp Fiction", "The Lord of the Rings: The Fellowship of the Ring", "The Good, the Bad and the Ugly"), director = c("Frank Darabont", "Francis Ford Coppola", "Christopher Nolan", "Francis Ford Coppola", "Sidney Lumet", "Steven Spielberg", "Peter Jackson", "Quentin Tarantino", "Peter Jackson", "Sergio Leone"), actor = c("Tim Robbins|Morgan Freeman|Bob Gunton", "Marlon Brando|Al Pacino|James Caan", "Christian Bale|Heath Ledger|Aaron Eckhart", "Al Pacino|Robert De Niro|Robert Duvall", "Henry Fonda|Lee J. Cobb|Martin Balsam", "Liam Neeson|Ralph Fiennes|Ben Kingsley", "Elijah Wood|Viggo Mortensen|Ian McKellen", "John Travolta|Uma Thurman|Samuel L. Jackson", "Elijah Wood|Viggo Mortensen|Ian McKellen", "Clint Eastwood|Eli Wallach|Lee Van Cleef") ) gallery <- treeGallery_rd3(tree, initialType="film", tableformat=TRUE, color="type", zoom=2) ## Not run: plot(gallery) ## End(Not run) # example with path preservation tree <- rbind( c("a1","b1","c1|c2"), c("a2","b2","c3|c4"), c("a3","b2","c4|c5"), c("a4","b3|b4","c6|c7|c8") ) colnames(tree) <- c("a","b","c") gallery <- treeGallery_rd3(tree, deep=TRUE, color="type") ## Not run: plot(gallery) ## End(Not run)
treeGallery2_rd3
produces an interactive image gallery (alternative display).
treeGallery2_rd3(tree, initialType = NULL, tableformat = FALSE, ...)
treeGallery2_rd3(tree, initialType = NULL, tableformat = FALSE, ...)
tree |
a data frame with two columns: source and target, describing relationships between nodes. It indicates a hierarchy between nodes which can be dynamically explored. Optionally, another two columns describing types can be passed. |
initialType |
A character vector indicating which node type will be shown at start. |
tableformat |
If the tree is especified as a table, one column per level. |
... |
Any gallery_rd3 argument. |
Object of class treeGallery_rd3
.
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
# Create some film data tree <- data.frame( film = c("The Shawshank Redemption", "The Godfather", "The Dark Knight", "The Godfather Part II", "12 Angry Men", "Schindler's List", "The Lord of the Rings: The Return of the King", "Pulp Fiction", "The Lord of the Rings: The Fellowship of the Ring", "The Good, the Bad and the Ugly"), director = c("Frank Darabont", "Francis Ford Coppola", "Christopher Nolan", "Francis Ford Coppola", "Sidney Lumet", "Steven Spielberg", "Peter Jackson", "Quentin Tarantino", "Peter Jackson", "Sergio Leone"), actor = c("Tim Robbins|Morgan Freeman|Bob Gunton", "Marlon Brando|Al Pacino|James Caan", "Christian Bale|Heath Ledger|Aaron Eckhart", "Al Pacino|Robert De Niro|Robert Duvall", "Henry Fonda|Lee J. Cobb|Martin Balsam", "Liam Neeson|Ralph Fiennes|Ben Kingsley", "Elijah Wood|Viggo Mortensen|Ian McKellen", "John Travolta|Uma Thurman|Samuel L. Jackson", "Elijah Wood|Viggo Mortensen|Ian McKellen", "Clint Eastwood|Eli Wallach|Lee Van Cleef") ) gallery <- treeGallery2_rd3(tree, initialType="film", tableformat=TRUE) ## Not run: plot(gallery) ## End(Not run)
# Create some film data tree <- data.frame( film = c("The Shawshank Redemption", "The Godfather", "The Dark Knight", "The Godfather Part II", "12 Angry Men", "Schindler's List", "The Lord of the Rings: The Return of the King", "Pulp Fiction", "The Lord of the Rings: The Fellowship of the Ring", "The Good, the Bad and the Ugly"), director = c("Frank Darabont", "Francis Ford Coppola", "Christopher Nolan", "Francis Ford Coppola", "Sidney Lumet", "Steven Spielberg", "Peter Jackson", "Quentin Tarantino", "Peter Jackson", "Sergio Leone"), actor = c("Tim Robbins|Morgan Freeman|Bob Gunton", "Marlon Brando|Al Pacino|James Caan", "Christian Bale|Heath Ledger|Aaron Eckhart", "Al Pacino|Robert De Niro|Robert Duvall", "Henry Fonda|Lee J. Cobb|Martin Balsam", "Liam Neeson|Ralph Fiennes|Ben Kingsley", "Elijah Wood|Viggo Mortensen|Ian McKellen", "John Travolta|Uma Thurman|Samuel L. Jackson", "Elijah Wood|Viggo Mortensen|Ian McKellen", "Clint Eastwood|Eli Wallach|Lee Van Cleef") ) gallery <- treeGallery2_rd3(tree, initialType="film", tableformat=TRUE) ## Not run: plot(gallery) ## End(Not run)