Type: | Package |
Version: | 2.1.9 |
Date: | 2025-06-27 |
Title: | Interactive Analytic Networks |
Description: | Create interactive analytic networks. It joins the data analysis power of R to obtain coincidences, co-occurrences and correlations, and the visualization libraries of 'JavaScript' in one package. |
License: | GPL-2 | GPL-3 |
Depends: | R (≥ 3.5.0) |
Imports: | rD3plot (≥ 1.1.37), igraph (≥ 1.0.1), Matrix (≥ 1.2-4), haven (≥ 1.1.0), MASS (≥ 7.3), GPArotation(≥ 2022.4), methods |
Suggests: | knitr, rmarkdown, lavaan, shiny, htmltools, openxlsx, data.table, readr |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Maintainer: | Modesto Escobar <modesto@usal.es> |
URL: | https://modesto-escobar.github.io/netCoin-2.x/ |
Encoding: | UTF-8 |
BugReports: | https://github.com/Modesto-Escobar/netCoin-2.x/issues |
Acknowledgments: | Grants CSO2013-49278-EXP, PGC2018-093755-B100, PDC2022-133355-100, PID2023-147358NB-100 funded by MICIU/AEI/10.13039/501100011033 and by “European Union NextGenerationEU/PRTR”. |
Packaged: | 2025-07-03 20:26:49 UTC; modes |
Author: | Modesto Escobar |
Repository: | CRAN |
Date/Publication: | 2025-07-03 21:10:01 UTC |
The netCoin package.
Description
Create interactive networked coincidences. It joins the data analysis power of R to study coincidences and the visualization libraries of JavaScript in one package.
Details
Coincidence analysis detects what events, characters, objects, attributes, or characteristics tend to occur together within certain limits.
These given limits are call scenarios (S
) and are considered to be the units of analysis, and as such they have to be placed in the rows of a matrix or data.frame.
In each i
scenario, a series of J
events X_j
, which are to be represented as dichotomous variables X_{j}
in columns, may occur (1) or may not occur (0). Scenarios and events constitute an incidence matrix (I).
Incidence matrix
X_1 | X_2 | X_3 | \; ... | X_J |
|
S_1 | 0 | 1 | 0 | ... | 1 |
S_2 | 1 | 0 | 1 | ... | 0 |
... | ... | ... | ... | ... | ... |
S_n | 1 | 1 | 0 | ... | 1 |
From this incidences matrix, a coincidence (C) matrix can be obtained with the function coin
. In this matrix the main diagonal represents frequencies of X_j
, while the others elements are number of coincidences between two events.
Coincidence matrix
X_1 | X_2 | X_3 | \; | X_J |
|
X_1 | 2 | 1 | 1 | ... | 1 |
X_2 | 1 | 2 | 0 | ... | 2 |
X_3 | 1 | 0 | 1 | ... | 0 |
... | ... | ... | ... | ... | ... |
X_J | 1 | 2 | 0 | ... | 2 |
Once there is a coin
object, a similarity matrix can be obtained. Similarity matrices available in netCoin are:
Matching (m), Rogers & Tanimoto (t) Gower (g) Sneath (s) and Anderberg (and).
Jaccard (j), dice (d), antiDice (a), Ochiai (o) and Kulczynski (k).
Hamann (ham), Yule (y), Pearson (p), odds ratio (od) and Rusell (r).
Other measures that can be obtained from coin
are:
Relative frequencies (x), conditional frequencies (i) coincidence degree (cc) and probable degree of coincidence (cp).
Haberman (h) and Z value of Haberman (z)
To obtain similarity and other measures matrices, the function sim
elaborates a list of them.
Similarity matrix
X_1 | X_2 | X_3 | \; | X_J |
|
X_1 | 1.73 | -.87 | .87 | ... | -.87 |
X_2 | -.87 | 1.73 | -1.73 | ... | 1.73 |
X_3 | .87 | -1.73 | 1.73 | ... | -1.73 |
... | ... | ... | ... | ... | ... |
X_J | -.87 | 1.73 | -1.73 | ... | 1.73 |
edgeList
makes a collecion of edges composed by a list of similarity measures whenever a criterium (generally p(Z)<.50) is met.
Edge list
source | target | Haberman | P(z) | |
1 | X1 | X3 | 0.8660254 | 0.22509243 |
2 | X2 | X4 | 1.7320508 | 0.09084506 |
In order to make a graph, two data frames are needed: a nodes data frames with names and other nodes attributes (see asNodes
) and an edge data frame (see edgeList
). For more information go to netCoin
.
Author
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. (2009): "Redes Semanticas en Textos Periodisticos: Propuestas Tecnicas para su Representacion", en Empiria, 17, 13-39.
Escobar, M.(2015): "Studying Coincidences with Network Analysis and Other Multivariate Tools", in The Stata Journal, 15(4), 1118-1156.
Escobar, M. and J. Gomez Isla (2015): "The Expression of Identity through the Image: The Photographic Archives of Miguel de Unamuno and Joaquin Turina", en Revista Espanola de Investigaciones Sociologicas, 152, 23-46.
Data: Finches' presence in Galapagos Islands.
Description
Data frame with absence(0) presence(1) of finches in the Galagos Islands.
Usage
data("Galapagos")
Format
A data frame with 17 localizations (islands) and 13 variables (Genus and species of the finches):
Geospiza magnirostris
Geospiza fortis
Geospiza fuliginosa
Geospiza difficilis
Geospiza scandens
Geospiza conirostris
Camarhynchus psitticula
Camarhynchus pauper
Camarhynchus parvulus
Platyspiza crassirostris
Cactospiza pallida
Cactospiza heliobates
Certhidea olivacea
References
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.
Examples
data(Galapagos)
head(Galapagos,10)
Adds a description to a 'netCoin' object.
Description
addDescription
adds a description to a 'netCoin' object.
Usage
addDescription(x, description)
Arguments
x |
A 'netCoin' object. |
description |
the description text. |
Value
A 'netCoin' object.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
data(finches)
data(Galapagos)
Net<-allNet(Galapagos,nodes=finches, criteria="hyp", maxL=.05,
lwidth ="Haberman",lweight="Haberman",
size="frequency", color="species", layout="mds",
main="Species coincidences in Galapagos Islands",
note="Data source: Sanderson (2000)")
img <- system.file("extdata", "p.Crassirostris.png",
package="netCoin")
Net <- addDescription(Net,"Species coincidences in Galapagos Islands")
## Not run:
multi <- multigraphCreate(Network=Net)
multiPages(multi,"Graph description example",show=TRUE)
## End(Not run)
Adds an image to a 'netCoin' object.
Description
addImage
adds an image to a 'netCoin' object.
Usage
addImage(x, img)
Arguments
x |
A 'netCoin' object. |
img |
character vector indicating the image path. |
Value
A 'netCoin' object.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
data(finches)
data(Galapagos)
Net<-allNet(Galapagos,nodes=finches, criteria="hyp", maxL=.05,
lwidth ="Haberman",lweight="Haberman",
size="frequency", color="species", layout="mds",
main="Species coincidences in Galapagos Islands",
note="Data source: Sanderson (2000)")
img <- system.file("extdata", "p.Crassirostris.png",
package="netCoin")
Net <- addImage(Net,img)
## Not run:
multi <- multigraphCreate(Network=Net)
multiPages(multi,"Graph image example",show=TRUE)
## End(Not run)
Networked coincidences.
Description
addNetCoin
changes netCoin object attributes.
Usage
addNetCoin(x, ...)
Arguments
x |
A 'netCoin' object. |
... |
Any netCoin argument. |
Value
This function returns a netCoin
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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
C <- coin(data) # coincidence matrix
N <- asNodes(C) # node data frame
E <- edgeList(C) # edge data frame
net <- netCoin(N, E) # netCoin object
net <- addNetCoin(net, color="frequency") # netCoin object with color applied to nodes
Adds a tutorial for the gallery.
Description
addTutorial
adds a tutorial for a gallery.
Usage
addTutorial(x, image = NULL, description = NULL)
Arguments
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. |
Value
Object of class gallery_rd3
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
data("finches")
finches$species <- system.file("extdata", finches$species,
package="netCoin") # copy path to the species field
g <- gallery(finches, image="species", main="Species in Galapagos Islands",
note="Data source: Sanderson (2000)")
g <- addTutorial(g,
description="Here you can see different finches species in Galapagos islands.")
## Not run:
plot(g)
## End(Not run)
Networked coincidences from incidences data.
Description
allNet
produces a network object of coincidences from a data frame or a matrix with dichotomous values.
Usage
allNet(incidences, weight = NULL, subsample = FALSE, pairwise = FALSE,
minimum=1, maximum = nrow(incidences),
sort = FALSE, decreasing = TRUE,
frequency = FALSE, percentages = TRUE,
procedures = "Haberman", criteria = "Z", Bonferroni = FALSE,
support = -Inf, minL = -Inf, maxL = Inf,
directed = FALSE, diagonal = FALSE,
sortL = NULL, decreasingL = TRUE,
igraph = FALSE, dir=NULL, ...)
Arguments
incidences |
an incidence matrix or data frame with only 0/1 variables. |
weight |
a vector of weights. Optimal for data.framed tables. |
subsample |
retrict the analysis to scenarios with at least one event. |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
minimum |
minimum frequency to be considered. |
maximum |
maximum frequency to be considered. |
sort |
sort the coincidence matrix according to frequency of events. |
decreasing |
decreasing or increasing sort of the matrix. |
frequency |
a logical value true if frequencies are to be shown. Default = FALSE. |
percentages |
a logical value true if percentages are to be shown. Default = TRUE. |
procedures |
a vector of statistics of similarity. See below. |
criteria |
statistic to be use for selection criteria. |
Bonferroni |
Bonferroni criterium of the signification test. |
support |
minimum value of the frequency of the coincidence to be edged. |
minL |
minimum value of the statistic to include the edge in the list. |
maxL |
maximum value of the statistic to include the edge in the list. |
directed |
includes same edges only once. |
diagonal |
includes auto-links. |
sortL |
sort the list according to the values of a statistic. See below. |
decreasingL |
order in a decreasing way. |
igraph |
Produces an igraph object instead of a netCoin object if TRUE. |
dir |
a "character" string representing the directory where the web files will be saved. |
... |
Any netCoin argument. |
Details
Possible measures in procedures are
Frequencies (f), Relative frequencies (x), Conditional frequencies (i), Coincidence degree (cc), Probable degree (cp),
Expected (e), Confidence interval (con)
Matching (m), Rogers & Tanimoto (t), Gower (g), Sneath (s), Anderberg (and),
Jaccard (j), Dice (d), antiDice (a), Ochiai (o), Kulczynski (k),
Hamann (ham), Yule (y), Pearson (p), odds ratio (od), Rusell (r),
Haberman (h), Z value of Haberman (z),
Hypergeometric p greater value (hyp).
Convert a matrix into an edge list (shape).
Value
This function creates a netCoin object (or igraph) and, if stated, 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
allNet(data) # network object
Images in a grid gallery.
Description
asGallery
produces a gallery_rd3 object.
Usage
asGallery(net)
Arguments
net |
is a |
Value
Object of class gallery_rd3
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
data("Galapagos")
data("finches")
finches$species <- system.file("extdata", finches$species,
package="netCoin") # copy path to the species field
Net <- allNet(Galapagos, nodes=finches, criteria="hyp", maxL=.05,
image="species",
main="Species coincidences in Galapagos Islands",
note="Data source: Sanderson (2000)")
gallery <- asGallery(Net)
Nodes data frame.
Description
Nodes data frame from either an edge list or a coin
object.
Usage
asNodes(C, frequency = TRUE, percentages = FALSE, language = c("en","es","ca"))
Arguments
C |
has to be an edge list or, better, a |
frequency |
add frequency of nodes |
percentages |
add nodes percentages |
language |
a character vector (es=spanish; en=english; ca=catalan). |
Value
A data frame with nodes' names and their frequency and/or percentages if the input is a coin
object
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# From a random incidence matrix I(25X4)
I <- matrix(rbinom(100, 1, .5), nrow = 25, ncol = 4,
dimnames = list(NULL, c("A", "B", "C", "D")))
C <- coin(I)
asNodes(C)
Networked coincidences.
Description
barCoin
produces a barCoin object.
Usage
barCoin(data, variables = colnames(data), commonlabel = NULL,
dichotomies = c("_all","_none"), valueDicho = 1, weight = NULL,
subsample = FALSE, sort = NULL, decreasing = TRUE, nodes = NULL,
name = NULL, select = NULL, scalebar = FALSE, note = NULL,
label = NULL, text = NULL, color = NULL, defaultColor = "#1f77b4",
expected = FALSE, confidence = FALSE, level = .95, significance = FALSE,
minimum = 1 , maximum = nrow(data), percentages = FALSE,
criteria = c("Z","hyp"), Bonferroni = FALSE,
support = 1, minL = -Inf, maxL = 1,
language = c("en","es","ca"), cex = 1.0, dir = NULL)
Arguments
data |
a data frame |
variables |
a vector of variables included in the previous data frame |
commonlabel |
a vector of variables whose names are to be included in nodes labels |
dichotomies |
a vector of dichotomous variables to appear as just one categorie |
valueDicho |
value to be selected for dichotomous variables. Default is 1 |
weight |
a vector of weights. Optimal for data.framed tables. |
subsample |
retrict the analysis to scenarios with at least one event. |
sort |
name of the vector in the nodes data frame to order the graph. |
decreasing |
decreasing or increasing sort of the graph order. |
nodes |
a data frame with at least two vectors of names and incidences. |
name |
name of the vector with names in the nodes data frame. |
select |
Name of the event (in nodes name column) to start the visualization. |
scalebar |
Should the bars fill the screen height? Default = FALSE. |
note |
lower title of the graph. |
label |
name of the vector with labels in the nodes data frame. |
text |
name of the vector with html text in the nodes data frame. |
color |
name of the vector with color variable in the nodes data frame. |
defaultColor |
a character vector giving a valid html color. |
expected |
name of the vector with expected coincidences in the links data frame. |
confidence |
name of the vector with confidence interval in the links data frame. |
level |
confidence level |
significance |
name of the vector with significance in the links data frame. |
minimum |
minimum frequency to be considered. |
maximum |
maximum frequency to be considered. |
percentages |
a logical value true if percentages are to be shown. Default = TRUE. |
criteria |
statistic to be use for selection criteria. |
Bonferroni |
Bonferroni criterium of the signification test. |
support |
minimum value of the frequency of the coincidence to be edged. |
minL |
minimum value of the statistic to include the edge in the list. |
maxL |
maximum value of the statistic to include the edge in the list. |
language |
a character vector (es=spanish; en=english; ca=catalan). |
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 web files will be saved. |
Value
Object of class barCoin
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
barCoin(data,dichotomies="_all")
barCoin(data,dichotomies="_all",confidence=TRUE,percentages=TRUE)
Categorize a network
Description
This function calculates the centrality measures of a network.
Usage
calCentr(graph,
measures = c("degree","wdegree","closeness","betweenness","eigen"),
order = "")
Arguments
graph |
A |
measures |
Character vector of the measures to be calculated (See details). |
order |
Sort the data.frame by the different measures. |
Details
This function reproduces some of the most significant classic Social Network Theory's centrality measures. See Wasserman (1994), Freeman (1978), or Bonacich & Lloyd (2001) to know more.
a) Degree = Degree centrality is measured by the total amount of direct links with the other nodes.
b) Closeness = Closeness centrality is meant to measure one node to the others nodes' sum distances
c) Betweenness = Betweenness centrality measures one node undertaking "mediation" role in a network.
d) Eigen = Eigenvector centrality measures a node's importance while giving consideration to the importance of its neighbors.
By default, measures = "all", thus all the measures will be calculated. The function can be applied to an igraph or a netCoin object. In case the graph is undirected, it will show the degree, weighted degree, closeness, betweeness and eigen degree. Moreover, if it us directed, it will show the indegree, windegree and outdegree, both weighted and unweighted (See example.).
Value
This function creates a list containing two elements: 1) a data.frame (nodes) with all the centrality measures applied to the graph and 2) another data.frame (graph) with this measures applied to the whole network.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
C <- coin(data) # coincidence matrix
N <- asNodes(C) # node data frame
E <- edgeList(C) # edge data frame
G <- netCoin(N, E, showArrows=TRUE) # netCoin object
calCentr(G, "all")
Produce interactive multi graphs.
Description
caring
produce an interactive multi graph from caring arguments.
Usage
caring(filepath,arguments)
Arguments
filepath |
The path to the data file. |
arguments |
a list with the caring exported arguments. |
Value
This function returns a mGraph
object.
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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
## Not run:
filename <- "demo.sav"
arguments <- list(
variables = c("Gender", "Income category in thousands",
"Primary vehicle price category"),
plot = "network"
)
graph <- caring(filename,arguments)
plot(graph)
## End(Not run)
Produce interactive multi graphs.
Description
caring_create_graphs
produce an interactive multi graph from caring arguments.
Usage
caring_create_graphs(data,arguments)
Arguments
data |
A data frame. |
arguments |
a list with the caring exported arguments. |
Value
This function returns a mGraph
object.
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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
data <- data.frame(Gender=c(rep("Man",3),rep("Woman",3)),
Opinion=c("Yes","Yes","No","No","No","Yes"))
arguments <- list(
variables = c("Gender", "Opinion"),
dichotomies = "Opinion",
valueDicho = "Yes",
plot = c("surCoin","network")
)
graph <- caring_create_graphs(data,arguments)
## Not run:
plot(graph)
## End(Not run)
Read sav, dta, xlsx, tsv and csv files.
Description
caring_read_file
reads sav, dta, xlsx, tsv and csv files and prepares data for caring.
Usage
caring_read_file(filepath)
Arguments
filepath |
The path to the data file. |
Value
This function returns a data frame.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
## Not run:
filename <- "demo.sav"
data <- caring_read_file(filename)
## End(Not run)
CobWeb graph (Upton).
Description
cobCoin
produces a netCoin object to graph a CoWeb graphic (Upton 2000).
Usage
cobCoin(data, variables=names(data), degree=0, significance=.05, ...)
Arguments
data |
a data frame. |
variables |
a vector of variables included in the previous data frame. |
degree |
degree to rotate the categories of the graph |
significance |
p value maximum to represent the links |
... |
Value
This function creates a netCoin object (or igraph) and, if stated, 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Upton, Graham J.G. (2000) Cobweb diagrams for multiway contingency tables. The Statistician, 49(1), 79-85.
Examples
# A data frame with two variables Gender and Opinion
frame <- data.frame(Gender=c(rep("Man",3),rep("Woman",3)),
Opinion=c("Yes","Yes","No","No","No","Yes"))
cobCoin(frame, significance=.5, degree=45) # netCoin object
# A data frame with two variables (Gender and Hand) and nodes
input <- data.frame(
Gender = c("Women", "Men", "Men", "Women", "Women","Men",
"Men", "Men", "Women", "Women", "Men", "Women"),
Hand = c("Right", "Left","Right", "Right", "Right", "Right",
"Left", "Right", "Right", "Left","Right", "Right"))
nodes <- data.frame(
name = c("Gender:Men","Gender:Women", "Hand:Left", "Hand:Right"),
label = c("Women(50\u25)","Men(50\u25)",
"Left hand(25\u25)", "Right hand(75\u25)"))
G <- cobCoin(input, nodes=nodes, label="label", degree=22.5,
showArrows=TRUE, significance=1)
coexist
Interactive network of time coexistences of periods.
Description
coexist
produces interactive graphs representing coexistence. Two periods or lifes coexist if they share a given number of years.
Usage
coexist(periods, name="name", start="start", end="end",
fields=names(periods), plusstart=0, minusend=0, igraph=FALSE, ...)
Arguments
periods |
a data frame with at least three vectors with name, start and end of the periods. |
name |
name of the vector with names in the periods data frame. |
start |
name of the vector with starts in the periods data frame. |
end |
name of the vector with ends in the periods data frame. |
fields |
vector of the names of the periods data frame to be taken into account. |
plusstart |
number of years to be trimmed at the beginning of each period. |
minusend |
number of years to be trimmed at the end of each period. |
igraph |
produces an igraph object instead of a netCoin class. |
... |
Any netCoin argument. |
Details
Two periods coexists if they have at least one year in common. Periods can be trimmed at the begining or at the end.
Value
This function creates a netCoin object (or igraph) and, if plotted, 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.
A netCoin object has three elements:
nodes |
A data frame with the periods. |
links |
A data frame with the events. |
options |
A list of options for the interactive graph. |
Note
Periods could be the life of people, in whose case start is their birth and end their death year.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
See Also
Examples
# With sociologists data.
data(sociologists)
# Produce an igraph object:
coexist(sociologists, start="birth", end="death", igraph=TRUE)
# Omit as coexistence the 15 firts years of life:
sociologists$picture <- system.file("extdata", sociologists$picture,
package="netCoin") # copy path to the picture field
coexist(sociologists, start="birth", end="death", plusstart=15, image="picture", imageName="name")
Coincidence matrix.
Description
A coin object is a squared matrix of coincidences with its names and the frequency of events as attributes.
Usage
coin(incidences, minimum = 1, maximum = nrow(incidences),
sort = FALSE, decreasing = TRUE,
total = FALSE, subsample = FALSE,
weight = NULL, pairwise = FALSE)
Arguments
incidences |
an incidence matrix or data frame with only 0/1 variables |
minimum |
minimum frequency to be considered |
maximum |
maximum frequency to be considered |
sort |
sort the coincidence matrix according to frequency of events |
decreasing |
decreasing or increasing sort of the matrix |
total |
add one first row and column with total |
subsample |
retrict the analysis to scenarios with at least one event |
weight |
a vector of weights. Optimal for data.framed tables |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
Details
Produce a matrix of coincidences from a matrix of incidences.
Value
An object of coin
class
n |
Number of scenarios (rows of the incidence matrix) |
f |
Coincidence matrix |
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
## Random incidence matrix: 25 scenarios, 4 events.
I <- matrix(rbinom(100, 1, .5), nrow = 25, ncol = 4,
dimnames = list(NULL, c("A", "B", "C", "D")))
coin(I, sort = TRUE)
## Hair by Eye by Sex table from M. Friendly (2000)
data(HairEyeColor)
H<-as.data.frame(HairEyeColor)
W<-H$Freq
I<-dichotomize(H,c("Hair","Eye","Sex"),add=FALSE)
coin(I,w=W)
Coocurrence matrix.
Description
A coocurrence object consists of a matrix with the number of ocurrences in its main diagonal and the number of coocurrences outside this diagonal. Besides, this object has two attributes: 1) n is the total of the sum of the ocurrences in each row.2) m is the sum of the maximum number of ocurrences in each row.
Usage
coocur(ocurrences, minimum = 1, maximum = Inf,
sort = FALSE, decreasing = TRUE)
Arguments
ocurrences |
an ocurrence matrix or data frame |
minimum |
minimum frequency to be considered |
maximum |
maximum frequency to be considered |
sort |
sort the coincidence matrix according to frequency of events |
decreasing |
decreasing or increasing sort of the matrix |
Details
Produce a matrix of coocurrences from a matrix of occurences.
Value
An object of cooc
class with a coocurrence matrix. It has two attributes:
n |
Total sum of occurences) |
m |
Sum of maximum occurences in each row of the ocurrence matrix |
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Tossing two coins five times.
D<-data.frame(Head=c(2,1,1,0,2),Tail=c(0,1,1,2,0))
coocur(D)
Dynamic networked correlations.
Description
netCorr
produces a network object of dynamic correlations. Its input has to be at least one set of quantitative variables.
Usage
d_netCorr(variables, nodes = NULL, weight=NULL,
pairwise=FALSE, minimum=-Inf, maximum=Inf,
frequency=FALSE, means=TRUE,
method=c("pearson", "kendall", "spearman"), criteria="value", Bonferroni=FALSE,
minL=0, maxL=Inf,
sortL=NULL, decreasingL=TRUE,
factorial=c("null", "pc", "nf", "vf", "of"),
components=TRUE, backcomponents=FALSE,
sequence=seq(.20, 1, .01), textFilter=c(1, .99), speed=50,
dir=NULL, ...)
Arguments
variables |
a data frame with at least two quantitative variables. |
nodes |
a data frame with at least one vector of names and other information from the nodes |
weight |
a vector of weights. Optimal for data.framed tables |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
minimum |
minimum mean to be considered |
maximum |
maximum mean to be considered |
frequency |
a logical value true if frequencies are to be shown. Default=FALSE. |
means |
a logical value true if means are to be shown. Default=TRUE. |
method |
a vector of statistics of similarity. Pearson correlation by default. Spearman and Kendall are also possible |
criteria |
statistic to be use for selection criteria. |
Bonferroni |
Bonferroni criterium of the signification test. |
minL |
minimum value of the statistic to include the edge in the list. |
maxL |
maximum value of the statistic to include the edge in the list. |
sortL |
sort the list according to the values of a statistic. See below |
decreasingL |
order in a decreasing way. |
factorial |
factorial layout: Principal components (pc), factorial (nf), factorial with varimax rotation (vf), and factorial with oblimin rotation (of) are possible |
components |
display following graph in sequence only when the components are unequal |
backcomponents |
display following graph in sequence even if there are less components |
sequence |
evolution of the dinamic graphs. c(first threshold, last threshold, step) |
textFilter |
limits for showing the correlations as text on the graph. This limit is the minimun value of the first (absolute), and the second (threshold plus its value) |
speed |
speed of the dynamic evolution from 0 to 100 |
dir |
a "character" string representing the directory where the web files will be saved. |
... |
any netCoin argument. |
Value
The function creates a list object to create a multigraph and eventually a folder in the computer with an HTML document named index.html which contains the produced dynamic graphs. This file can be directly opened with your browser and sent to a web server to work properly.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# A character column (with separator)
data(iris)
d_netCorr(iris[,1:4],ltext="value", sequence=seq(.80, 1, .05), zoom=3, textFilter=.85,
main="Correlations between measurements of Iris Species", components=FALSE,
note="Anderson, Edgar (1935) y Fisher, R. A. (1936)") # network object
Data: Roll a die (100 times).
Description
Data frame with events as result.
Usage
data("dice")
Format
A data frame with 100 observations (scenarios) on the following 11 variables (events):
dice
: a numeric vector, representing dice results
1
: a dichotomous vector of the elemental event "1"
2
: a dichotomous vector of the elemental event "2"
3
: a dichotomous vector of the elemental event "3"
4
: a dichotomous vector of the elemental event "4"
5
: a dichotomous vector of the elemental event "5"
6
: a dichotomous vector of the elemental event "6"
odd
: a dichotomous vector of odd events
even
: a dichotomous vector of even events
small
: a dichotomous vector of small number events
large
: a dichotomous vector of large number events
Source
Random extraction via sample(1:6,100,replace=TRUE)
References
See events.
Examples
data(dice)
head(dice,10)
Dichotomize.
Description
This converts factor(s) o character(s) column(s) of a data frame into a set of dichotomous columns. Their names will correspond to the labels or text of every category.
Usage
dichotomize(data, variables,
sep = "", min = 1, length = 0, values = NULL,
sparse = FALSE, add = TRUE, sort = TRUE, nas = "None")
Arguments
data |
a data frame with a factor or textual column which can be simple (only one value for each scenario) or multiple if components are delinited with a separator. |
variables |
vector of column names that have to be converted into dichotomous vectors. |
sep |
vector of characters used to divide columns with multiple events. If this separator is "", every unique cell of every column is converted into a dichotomus data frame's column. |
min |
convert to dichotomous vectors only label or text that has a frequency less or equal to the value of this parameter. If the value of min is between 0 and 1, its value is interpreted as a percentage |
length |
maximum number of dichotomous columns generated for every variable |
values |
vector of labels or texts selected to their conversion to dichotomous columns |
sparse |
produce a sparse matrix instead of a data.frame |
add |
add the new columns to the input data.frame |
sort |
order the new columns by their frequencies |
nas |
variable name to convert the NA values of the set of variables |
Value
A data frame composed by the original plus the added dichotmous columns.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca, and Luis Martinez Uribe, Fundacion Juan March. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# A character column
frame1 <- data.frame(A = c("Man", "Women", "Man", "Undet."))
dichotomize(frame1, "A", sep = "; ")
# A character column (with separator)
frame2 <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
dichotomize(frame2, "A", sep = "; ")
# A character column and another factor column (same sepatator)
frame3 <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"),
C = factor(c(1:4), labels = c("Paris", "New York",
"London; New York", "<NA>")))
dichotomize(frame3, c("A", "C"), sep = "; ")
# A set of simple character or factor (same levels) variables.
# In this case, you must use "C" separator.
frame4 <- data.frame(A = c("Man", "Women","Man", "Undet",NA),
B = c("Women","Women","Man","Women",NA),
C = c(NA,NA,NA,"Man",NA))
dichotomize(frame4,c("A","B","C"), sep="C")
Distance matrix.
Description
Convert a similarity matrix into a distance matrix.
Usage
distant(s, t = FALSE)
Arguments
s |
a similarity matrix |
t |
return the same matrix if t=FALSE |
Details
For better resultas, use the parameter distance in sim
function.
Value
A distance matrix.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# From a random incidence matrix I(25X4)
I <- matrix(rbinom(100, 1, .5), nrow = 25, ncol = 4,
dimnames = list(NULL, c("A", "B", "C", "D")))
J <- sim(I, "Jaccard")
distant(J, t = TRUE)
#Same results
sim(I, "Jaccard", distance = TRUE)
Interactive graphs of dynamic cohorts.
Description
dyncohort
produces interactive graphs representing dynamic cohorts. Two periods or lifes belongs to the same cohort if there are a difference of years in their start less or equal to a given number. In case of people's life, 15 or 25 are appropiate quantities to set. If year is equal to 0, a cohort is defined a those periods or lifes that begin at the same year.
Usage
dyncohort(periods, name="name", start="start", fields=names(periods),
years=0, igraph=FALSE, ...)
Arguments
periods |
a data frame with at least two vectors with name and start of the periods or lives. |
name |
name of the vector with names in the data frame. |
start |
name of the vector with starts in the data frame. |
fields |
vector of the names of the periods data frame to be taken into account. |
years |
number of years to be considered as length of the cohort. |
igraph |
produces an igraph object instead of a netCoin class. |
... |
Any netCoin argument. |
Value
This function creates a timeCoin object (or igraph) and, if plotted, 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.
A netCoin object has three elements:
nodes |
A data frame with the periods. |
links |
A data frame with the events. |
options |
A list of options for the interactive graph. |
Note
Periods could be the life of people, in whose case start is their birth year.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
See Also
Examples
# With sociologists data.
data(sociologists)
dyncohort(sociologists, start="birth")
# Condider 15 year dynamic cohort:
sociologists$picture <- system.file("extdata", sociologists$picture,
package="netCoin") # copy path to the picture field
dyncohort(sociologists, start="birth", year=15, image="picture", imageName="name")
Edge list.
Description
Convert a coincidence/similarity/distance matrix into an edge list form.
Usage
edgeList(data, procedures="Haberman",
criteria="Z", level=.95, Bonferroni=FALSE,
min=-Inf, max=Inf, support=-Inf, directed=FALSE,
diagonal=FALSE, sort=NULL, decreasing=TRUE, pairwise=FALSE)
Arguments
data |
a coin object, let's say an R matrix with frequencies and an attribute ( |
procedures |
a vector of statistics of similarity. See below. |
criteria |
statistic to be use for selection criteria. |
level |
confidence level |
Bonferroni |
Bonferroni criterium of the signification test. |
min |
minimum value of the statistic to include the edge in the list. |
max |
maximum value of the statistic to include the edge in the list. |
support |
minimum value of the frequency of the coincidence to be edged |
directed |
includes same edges only once. |
diagonal |
includes auto-links |
sort |
sort the list according to the values of a statistic. See below |
decreasing |
order in a decreasing way. |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
Details
Possible measures in procedures are
Frequencies (f), Relative frequencies (x), Conditional frequencies (i), Coincidence degree (cc), Probable degree (cp),
Expected (e), Confidence interval (con)
Matching (m), Rogers & Tanimoto (t), Gower (g), Sneath (s), Anderberg (and),
Jaccard (j), Dice (d), antiDice (a), Ochiai (o), Kulczynski (k),
Hamann (ham), Yule (y), Pearson (p), odds ratio (od), Rusell (r),
Haberman (h), Z value of Haberman (z),
Hypergeometric p greater value (hyp).
Convert a matrix into an edge list (shape).
Value
A data frame in which the two first columns are source and target. The rest of the columns are the different statistics explicited in funcs
parameter.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# From a random incidence matrix I(25X4)
I<-matrix(rbinom(100,1,.5),nrow=25,ncol=4,
dimnames=list(NULL,c("A","B","C","D")))
C<-coin(I)
edgeList(C)
Data: European Social Survey, Round-8.
Description
A sample size of 1,000 respondents from the European Social Survey, Round-8.
Usage
data("ess")
Format
A data frame with 1000 cases (respondents) and 5 variables:
Gender
Gender (factor vector): Female, Male.
Age
Age (recoded factor vector): 15-29, 30-30, 40-49, 50-59, 60-69, 70 and +.
Social participation
Social participation (factor vector): No, Yes.
Political participation
Political participation (factor vector): No, Yes.
cweight
cweight (numeric vector): Cases weight.
References
ESS Round 8: European Social Survey Round 8 Data (2016). Data file edition 2.1. NSD - Norwegian Centre for Research Data, Norway - Data Archive and distributor of ESS data for ESS ERIC. doi:10.21338/NSD-ESS8-2016.
Examples
data("ess")
head(ess,10)
Data: Attributes of the dice events.
Description
Data frame with the attributes of the events of dice.
Usage
data("events")
Format
A data frame with 10 observations on the following 4 variables:
name
: a factor vector with 10 levels
label
: a factor vector with 10 levels
frequency
: a numeric vector
type
: a factor vector with 2 levels
Source
data(dice); coin.dice<-coin(dice); asNodes(coin.dice)
References
See dice
.
Examples
data(events)
events
Images in a grid gallery.
Description
exhibit
produces an interactive image gallery (alternative display).
Usage
exhibit(nodes, name = NULL, label = NULL, subtitle = NULL, order = NULL,
decreasing = FALSE, ntext = NULL,
mainframeHeight = NULL, mainframeWidth = NULL,
image = NULL, zoom = NULL, main = NULL, note = NULL,
frequencies = FALSE, tutorial = FALSE, tableButton = FALSE, export = FALSE,
colorScheme = 0, language = c("en", "es", "ca"), dir = NULL)
Arguments
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. |
mainframeWidth |
a number to proportionally change mainframe width. |
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. |
frequencies |
a logical value true if barplots representing node attributes frequencies will be added to the final 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. |
Value
Object of class gallery_rd3
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
data("finches")
finches$species <- system.file("extdata", finches$species,
package="netCoin") # copy path to the species field
exhibit(finches, image="species")
Expected list.
Description
Converts a coin
object to a links data frame with coincidences and expected values.
Usage
expectedList(data, names = NULL, min = 1, confidence=FALSE)
Arguments
data |
is a |
names |
a character vector. |
min |
minimum value of the statistic to include the edge in the list. |
confidence |
add the confidence interval if TRUE. |
Value
A links data frame with coincidences and expected values.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
C <- coin(data) # coincidence matrix
expectedList(C) # edge data frame
Data: Italian families in the Renaissance.
Description
Data frame with the characteristics of powerful families of Renaissance Italy.
Usage
data("families")
Format
A data frame with 16 families (rows) and 6 characteristics.
name
Family's name
f.Marriages
number of marriage links
f.Business
number of business links
wealth
wealth's index
priorates
number of priorates on control
seat
At least priorate
Source
PADGETT, J. F. Y C. K. ANSELL (1993): "Robust Action and the Rise of the Medici, 1400-1434", in American Journal of Sociology, 98, 1259-1319. (http://www.jstor.org/stable/2781822)
Examples
data("families")
head(families)
Data: Finches'attributes in Galapagos islands.
Description
Data frame with events as result.
Usage
data("finches")
Format
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
References
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.
Examples
data(finches)
head(finches,10)
Produce interactive networks from igraph objects.
Description
fromIgraph
produce an interactive network from an igraph object.
Usage
fromIgraph(G, ...)
Arguments
G |
an igraph object. |
... |
Any netCoin argument. |
Value
This function returns a netCoin
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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
g <- igraph::make_ring(10)
fromIgraph(g)
Images in a grid gallery.
Description
gallery
produces an interactive image gallery.
Usage
gallery(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)
Arguments
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. |
Value
Object of class gallery_rd3
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
data("finches")
finches$species <- system.file("extdata", finches$species,
package="netCoin") # copy path to the species field
gallery(finches, image="species", main="Species in Galapagos Islands",
note="Data source: Sanderson (2000)")
Create an html panel for nodes from different items (for galleries).
Description
Create an html panel for nodes from different items (for galleries).
Usage
get_panel_template(data, title=NULL, description=NULL, img=NULL,
text=NULL, color="auto", cex=1, mode = 1)
Arguments
data |
data frame which contains the data. |
title |
column name which contains the first title of the vignette. |
description |
column name which contains the main text of the vignette. |
img |
column name which contains the names of the image files. |
text |
column name which contains the main text of the vignette. |
color |
color of the panel (It also could be a column name which contains colors). |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. |
mode |
There are two display modes. |
Value
a character vector of html formatted panel.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Not run:
data("sociologists")
sociologists$picture <- system.file("extdata", sociologists$picture,
package="netCoin")
sociologists$html <- get_panel_template(sociologists, title="name",
description="birth_country",img="picture", text="school")
plot(gallery(sociologists, info="html"))
## End(Not run)
Create a drop-down vignette for nodes from different items (for galleries).
Description
Create a drop-down vignette for nodes from different items (for galleries).
Usage
get_template(
data,
title = NULL,
title2 = NULL,
text = NULL,
img = NULL,
wiki = NULL,
width = 300,
color = "auto",
cex = 1,
roundedImg = FALSE,
mode = 1
)
Arguments
data |
data frame which contains the data. |
title |
column name which contains the first title of the vignette. |
title2 |
column name which contains the secondary title of the vignette. |
text |
column name which contains the main text of the vignette. |
img |
column name which contains the names of the image files. |
wiki |
column name which contains the wiki URL for the vignette. |
width |
length of the vignette's width. |
color |
color of the vignette's strip (It also could be a column name which contains colors). |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. |
roundedImg |
Display images with rounded borders. |
mode |
2 display images next to the text. 1 by default. |
Value
a character vector of html formatted vignettes.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Not run:
data("sociologists")
sociologists$picture <- system.file("extdata", sociologists$picture,
package="netCoin")
sociologists$html <- get_template(sociologists, title="name",
title2="birth_country", text="school",img="picture", mode=2)
plot(gallery(sociologists, ntext="html"))
## End(Not run)
Create a drop-down vignette for nodes from different items (for galleries).
Description
Create a drop-down vignette for nodes from different items (for galleries).
Usage
get_template2(data, title=NULL, title2=NULL, text=NULL, wiki=NULL)
Arguments
data |
data frame which contains the data. |
title |
column name which contains the first title of the vignette. |
title2 |
column name which contains the secondary title of the vignette. |
text |
column name which contains the main text of the vignette. |
wiki |
column name which contains the wiki URL for the vignette. |
Value
a character vector of html formatted vignettes.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Not run:
data("sociologists")
sociologists$html <- get_template2(sociologists, title="name",
title2="birth_country", text="school")
plot(exhibit(sociologists, ntext="html"))
## End(Not run)
Regression Graphs
Description
produces a netCoin object from a set of glm regressions.
Usage
glmCoin(formulas, data, weights=NULL, pmax=.05,
twotail=FALSE, showArrows=TRUE,
frequency = FALSE, percentage = TRUE,
color="variable", lwidth="z.value",
circle= NA, language=c("en","es","ca"),
igraph=FALSE, ...)
Arguments
formulas |
A set of formulas separated, folowed by the family and a return. For example: model <- "counts ~ outcome + treatment, poisson counts ~ outcome, poisson" |
data |
Data frame containing the variables in the model. |
weights |
Optional vector of weights to be used in the fitting process. |
pmax |
Selection of links with Pr(>|z|) less than p (one-tail by default). |
twotail |
Logical value indicating if twotail test must be appied. Defaul=FALSE. |
showArrows |
a logical value true if the directional arrows are to be shown. Default = FALSE. |
frequency |
a logical value true if frequencies are to be shown. Default=FALSE. |
percentage |
a logical value true if percentages are to be shown. Default=TRUE. |
color |
Nodes' attribute to be used for expressing color ("variable" by default). |
lwidth |
Nodes' attribute to be used for widht of arrows ("z.value" by default). |
circle |
Degre of rotation in case of fixed circled dependent variables. |
language |
Language of the graph controls. |
igraph |
Produces an igraph object instead of a netCoin object if TRUE. |
... |
Any netCoin argument. |
Value
This function creates a netCoin object (or igraph) and, if stated, 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
Dobson <- data.frame(counts=counts, outcome=outcome, treatment=treatment)
model <- "counts ~ outcome + treatment, poisson"
glmCoin(model,Dobson)
Time incidences.
Description
Convert a data frame with two numbers (normally a beginning year and end year) into an incidences matrix whose rows are the intermediate numbers, and whose columns are the content of the names column.
Usage
incTime(data, name = "name", beginning = "birth", end= "death")
Arguments
data |
a data frame a name and two numbers. |
name |
Column with the names (default= "name"). |
beginning |
Column with the beginning number to include (default= "birth"). |
end |
Column with the end number to include (default= "death"). |
Value
A data frame in which the two first columns are source and target. The rest of the columns are sim.=(1+threshold-real difference) and dist.=(difference between numbers)
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# From sociologists data
data("sociologists")
head(incTime(sociologists))[,1:5]
Produce a circle layout of any number of nodes.
Description
layoutCircle
produces a circle layout of any number of nodes.
Usage
layoutCircle(N,nodes=seq_len(nrow(N)),deg=0,name=NULL)
Arguments
N |
a data frame of nodes. |
nodes |
a vector specifing nodes. |
deg |
degrees to rotate. |
name |
name of column with node names. |
Value
This function returns the input data frame of nodes with the resulting layout applied.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
A <- data.frame(name=letters)
L <- layoutCircle(A,name="name")
netCoin(A,layout=L)
Produce a layout of any number of nodes.
Description
layoutGrid
produces a grid layout of any number of nodes.
Usage
layoutGrid(N,string,name=NULL,byrow=FALSE)
Arguments
N |
a data frame of nodes. |
string |
a character vector specifing grouped nodes. |
name |
name of column with node names. |
byrow |
logical. If 'FALSE' (the default) the layout is filled by columns, otherwise the layout is filled by rows. |
Value
This function returns the input data frame of nodes with the resulting layout applied.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
A <- data.frame(name=letters)
L <- 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")
netCoin(A,layout=L)
Data: Links between Italian families in the Renaissance.
Description
Data frame with the marriage and business links.
Usage
data("links")
Format
A data frame with 36 links (rows) amongst 16 Italian families in the Renaissance.
Albizzi
Acciaiuoli
Barbadori
Bischeri
Castellani
Guadagni
Lamberteschi
Medici
Pazzi
Peruzzi
Ridolfi
Salviati
Strozzi
Tornabuoni
Ginori
Pucci
link
Type of link: marriage or business
Source
PADGETT, J. F. Y C. K. ANSELL (1993): "Robust Action and the Rise of the Medici, 1400-1434", in American Journal of Sociology, 98, 1259-1319. (http://www.jstor.org/stable/2781822)
Examples
data("links")
head(links)
Networked log-linear models.
Description
logCoin
produces a network object from loglinear models parameters.
Usage
logCoin(data, variables=names(data), exogenous=NULL, noFirstCat= NULL,
weight=NULL, order= 2, pairwise=FALSE, twotails = FALSE,
pmax = 0.05, frequency = FALSE, percentage = FALSE,
directed=FALSE, igraph=FALSE, ...)
Arguments
data |
a data frame. |
variables |
a vector of names of variables included in the previous data frame. |
exogenous |
a vector of names of variables whose relations amongst them are of no interest. None by default. |
noFirstCat |
a vector of names of dichotomous variables to appear without the category (no characteristic). |
weight |
a vector of weights. Optimal for dataframed tables. |
order |
maximum order parameters to be included in the loglinear model (default=2) |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
twotails |
Application of twotail tests to the parameters (default: FALSE, i.e., onetail) |
pmax |
maximum value of the statistic to include the edge in the list. By default is 0.05, but 0.5 is recommended if data has not been sampled. |
frequency |
a logical value true if frequencies are to be shown. Default=FALSE. |
percentage |
a logical value true if percentages are to be shown. Default=TRUE. |
directed |
includes arrows to the links (target would be the categories of first mention variables). |
igraph |
Produces an igraph object instead of a netCoin object if TRUE. |
... |
Any netCoin argument. |
Value
This function creates a netCoin object (or igraph) and, if stated, 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# A n=1,000 sample from the European Social Survey.(Round 8, 2016)
data("ess")
logCoin(ess, c("Social participation", "Political participation"),
noFirstCat=c("Social participation", "Political participation"),
exogenous=c("Age", "Gender"), weight = "cweight",
order=3, pmax=.05,percentage = TRUE, frequency = TRUE ) # network object
Similarity/distance matrix display.
Description
Display the lower part of a matrix with a specified number of decimals.
Usage
lower(matrix, decimals = 3)
Arguments
matrix |
a symmetric similarity/distance matrix |
decimals |
number of decimals to be displayed |
Value
A data frame of characters.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# From a random incidence matrix I(25X4)
I <- matrix(rbinom(100, 1, .5), nrow = 25, ncol = 4,
dimnames = list(NULL, c("A", "B", "C", "D")))
lower(sim(I, "Jaccard"), 2)
Create a vignette (for galleries).
Description
Create a vignette from w_EntityInfo from wikiTools package (for galleries).
Usage
makeT(data, imageDir=NULL, imageDefault=NULL, language=c("en","es","ca"))
Arguments
data |
A data-frame created with |
imageDir |
A directory where images will be found. The name must be the 'entity' column content follow by the image extension and the allowed formats are jpg, jpeg, gif, png and svg. |
imageDefault |
This image will be assigned if 'entity' image is not found in |
language |
a character string indicating the language of the graph (en=english (default); es=spanish; ca=catalan). |
Value
a data frame wich includes a column of html formatted vignettes called 'info'.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Create a vignette (for galleries).
Description
Create a vignette from some specific information supplied (for galleries).
Usage
makeT2(entityLabel, image=NA, entityDescription=NA,
byear=NA, bplace=NA, bcountry=NA, dyear=NA, dplace=NA, dcountry=NA,
gender=NA, occupation=NA, language=c("en","es","ca"))
Arguments
entityLabel |
A character string of names. |
image |
A character string of image paths. |
entityDescription |
A character string of descriptions. |
byear |
A character string of birth years. |
bplace |
A character string of birth places. |
bcountry |
A character string of birth countries. |
dyear |
A character string of death years. |
dplace |
A character string of death places. |
dcountry |
A character string of death countries. |
gender |
A character string of genders. |
occupation |
A character string of occupations. |
language |
a character string indicating the language of the graph (en=english (default); es=spanish; ca=catalan). |
Value
a data frame wich includes a column of html formatted vignettes called 'info'.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Mobile Edges.
Description
Convert a data frame with one number (normally a year) into an edge list form with those whose numbers (years) have a difference lower or equal to a quantity.
Usage
mobileEdges(data, name = 1, number = 2, difference=0)
Arguments
data |
a data frame with a name and a number (year). |
name |
Column with the names (default= first column). |
number |
Column with the number (year) to compare (default= second column. |
difference |
Minimum difference between numbers of every two pair of names to create the edge or link (default=15). |
Value
A data frame in which the two first columns are source and target. The rest of the columns are sim.=(1+threshold-real difference) and dist.=(difference between numbers)
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# From a random incidence matrix I(25X4)
data("sociologists")
mobileEdges(sociologists)
Produces a gallery of 'netCoin' graphs.
Description
multiPages
produces a gallery page to explore multiple 'netCoin' graphs.
Usage
multiPages(x, title = NULL, columns = NULL, imageSize = NULL,
description = NULL, note = NULL,
cex = 1, dir = tempDir(), show = FALSE)
Arguments
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. |
Value
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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
C <- coin(data) # coincidence matrix
N <- asNodes(C) # node data frame
E <- edgeList(C,c("frequency","expected","haberman")) # edge data frame
bC<- barCoin(data,dichotomies="_all") # barCoin object
cC<- barCoin(data,dichotomies="_all",expected=TRUE) # barCoin object
nC<- netCoin(N,E) # netCoin object
multi <- multigraphCreate("Bar graph" = bC,
"Conditional bar graph" = cC,
"Net graph"=nC)
## Not run:
multiPages(multi,"Some graphs",show=TRUE)
## End(Not run)
Produce interactive multi graphs.
Description
multigraphCreate
produce an interactive multi graph.
Usage
multigraphCreate(..., mode = c("default","parallel","frame"),
mfrow = c(1,2),
frame = 0, speed = 50, loop = FALSE, lineplots = NULL,
dir = NULL, show = FALSE)
Arguments
... |
rD3plot graphs (network_rd3, barplot_rd3, timeplot_rd3) objects or html "directories". |
mode |
a string specifying the displaying mode. The "default" displays graphs one by one, "parallel" splits screen and "frame" allows dinamic graphs in time. |
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. (Only applied in 'parallel' mode) |
frame |
number of frame to start a dynamic network. |
speed |
a percentage for frame speed in dynamic networks. |
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. |
show |
a logical value true if the graph is to be shown. Default = FALSE. |
Value
This function returns a mGraph
object.
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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
C <- coin(data) # coincidence matrix
N <- asNodes(C) # node data frame
E <- edgeList(C,c("frequency","expected","haberman")) # edge data frame
bC<- barCoin(data,dichotomies="_all") # barCoin object
cC<- barCoin(data,dichotomies="_all",expected=TRUE) # barCoin object
nC<- netCoin(N,E) # netCoin object
multi <- multigraphCreate("Bar graph" = bC,
"Conditional bar graph" = cC,
"Net graph"=nC)
## Not run:
plot(multi)
## End(Not run)
Networked coincidences.
Description
netCoin
produces a netCoin object of coincidences. 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.
Usage
netCoin(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,
centrality = NULL,
nodeBipolar = FALSE, nodeFilter = NULL, degreeFilter = 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)
Arguments
nodes |
a data frame with at least one vector of names. |
links |
a data frame with at least two vectors with source and target, including names of nodes. |
tree |
a data frame with two vectors: source and target, describing relationships between nodes. |
name |
name of the vector with names in the nodes data frame. By default, if language="en", name is "name". |
label |
name of the vector with labels in the nodes data frame. |
group |
name of the vector 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") |
centrality |
calculates the centrality measures of a network. See calCentr. |
labelSize |
name of the vector with label size in the nodes data frame. |
size |
name of the vector with size in the nodes data frame. |
color |
name of the vector with color variable in the nodes data frame. |
shape |
name of the vector with shape variable in the nodes data frame. |
border |
name of the column with border width in the nodes data frame. |
legend |
name of the vector with the variable to represent as a legend in the nodes data frame. |
ntext |
name of the vector with html text in the nodes data frame. |
info |
name of the vector with information to display in a panel in the nodes data frame. |
sort |
name of the vector 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 vector with intensity variable in the links data frame (only for heatmap). |
lwidth |
name of the vector with width variable in the links data frame. |
lweight |
name of the vector with weight variable in the links data frame. |
lcolor |
name of the vector with color variable in the links data frame. |
ltext |
name of the vector with labels in the links data frame. |
nodeFilter |
condition for filtering nodes. |
linkFilter |
condition for filtering links. |
degreeFilter |
numeric vector to filter the resulting network by degree. |
nodeBipolar |
a logical value that polarizes negative and positive node values in the graphical representation. Default = FALSE. |
linkBipolar |
a logical value that polarizes negative and positive link values in the graphical representation. Default = FALSE. |
defaultColor |
a character vector giving a valid html color. |
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 the frequencies can be shown in barplots. Default = FALSE. |
help |
help text of the graph. |
helpOn |
Should the help be shown at the beginning? |
background |
background color or image of the graph. |
layout |
a matrix with two columns or an algorithm to elaborate the coordinates: 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 size references to display layout, must be a numeric vector of length 4: x1, y1, x2, y2. |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. Default = 1. |
roundedItems |
Display items 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. Default = TRUE. |
showAxes |
a logical value true if the axes are to be shown. Default = FALSE. |
axesLabels |
a character vector giving the axes names. |
language |
a character vector (es=spanish; en=english; ca=catalan). |
image |
name of the vector with image files in the nodes data frame. |
imageNames |
name of the vector with names for image files in the nodes data frame. |
dir |
a "character" string representing the directory where the web files will be saved. |
Value
This function returns a netCoin
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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
C <- coin(data) # coincidence matrix
N <- asNodes(C) # node data frame
E <- edgeList(C) # edge data frame
netCoin(N, E) # netCoin object
Networked correlations.
Description
netCorr
produces a network object of correlations. Its input has to be at least one set of quantitative variables.
Usage
netCorr(variables, weight=NULL, pairwise=FALSE,
minimum=-Inf, maximum=Inf, sort=FALSE, decreasing=TRUE,
frequency=FALSE, means=TRUE,
method=c("pearson", "kendall", "spearman"),
criteria="p", Bonferroni=FALSE, minL=0, maxL=Inf,
sortL=NULL, decreasingL=TRUE,
igraph=FALSE, ...)
Arguments
variables |
a data frame with at least two quantitative variables. |
weight |
a vector of weights. Optimal for data.framed tables |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
minimum |
minimum frequency to be considered |
maximum |
maximum frequency to be considered |
sort |
sort the correlation matrix according to the frequency of the events |
decreasing |
decreasing or increasing sort of the matrix |
frequency |
a logical value true if frequencies are to be shown. Default=FALSE. |
means |
a logical value true if means are to be shown. Default=TRUE. |
method |
a vector of statistics of similarity. Pearson correlation by default. spearman and kendall are also possible |
criteria |
statistic to be use for selection criteria. |
Bonferroni |
Bonferroni criterium of the signification test. |
minL |
minimum value of the statistic to include the edge in the list. |
maxL |
maximum value of the statistic to include the edge in the list. |
sortL |
sort the list according to the values of a statistic. See below |
decreasingL |
order in a decreasing way. |
igraph |
Produces an igraph object instead of a netCoin object if TRUE |
... |
Any netCoin argument. |
Value
The function creates a netCoin object and eventually 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# A character column (with separator)
data(iris)
netCorr(iris[,1:4],ltext="value",
main="Correlations between measurements of Iris Species",
note="Anderson, Edgar (1935) y Fisher, R. A. (1936)") # network object
Images in a grid gallery.
Description
netExhibit
produces an interactive image gallery (alternative display).
Usage
netExhibit(tree, initialType = NULL, tableformat = FALSE, ...)
Arguments
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 exhibit argument. |
Value
Object of class treeGallery_rd3
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
# 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 <- netExhibit(tree, initialType="film", tableformat=TRUE)
## Not run:
plot(gallery)
## End(Not run)
Images in a grid gallery.
Description
netGallery
produces an interactive image gallery.
Usage
netGallery(tree, deep = FALSE, initialType = NULL, tableformat = FALSE, ...)
Arguments
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 argument. |
Value
Object of class netGallery
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca.
Examples
# 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 <- netGallery(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 <- netGallery(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<-netGallery(tree,deep=TRUE,color="type")
## Not run:
plot(gallery)
## End(Not run)
Structural Equation Models Graphs.
Description
pathCoin
produces a netCoin object from a lavaan object, i.e., parameters of structural equation model.
Usage
pathCoin(model, estimates=c("b","se","z","pvalue","beta"),
fitMeasures=c("chisq", "cfi", "rmsea"), ...)
Arguments
model |
a lavaan object. |
estimates |
A vector with at least one element amongst "b", "se", "z", "pvalue", "beta". |
fitMeasures |
Default values: "chisq", "df", "pvalue", "cfi", "rmsea" |
... |
Any netCoin argument. |
Value
The function creates a netCoin object and eventually 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# Classic Wheaton et al. model
library(lavaan)
lower <- '
11.834
6.947 9.364
6.819 5.091 12.532
4.783 5.028 7.495 9.986
-3.839 -3.889 -3.841 -3.625 9.610
-21.899 -18.831 -21.748 -18.775 35.522 450.288 '
wheaton.cov <- getCov(lower,
names = c("anomia67", "powerless67","anomia71", "powerless71",
"education", "sei"))
wheaton.model <- '
# latent variables
ses =~ education + sei
alien67 =~ anomia67 + powerless67
alien71 =~ anomia71 + powerless71
# regressions
alien71 ~ alien67 + ses
alien67 ~ ses
# correlated residuals
anomia67 ~~ anomia71
powerless67 ~~ powerless71
'
fit <- sem(wheaton.model, sample.cov = wheaton.cov, sample.nobs = 932)
pathCoin(fit)
pie charts.
Description
It generates pie charts from a coin object.
Usage
pieCoin(x, colors = c("#000000","#8dc7e6", "#ffffff","#005587"),
nodes = NULL, links = NULL, name = NULL, lcolor = NULL, expected = TRUE,
abline = NULL, main = NULL, note = NULL, showLegend = TRUE, help = NULL,
helpOn = FALSE, cex = 1, language = c("en", "es", "ca"), dir = NULL)
Arguments
x |
a |
nodes |
a data frame with information for each event. |
links |
a data frame with information for each pie. |
name |
name of the column with names in the nodes data frame. |
colors |
a vector of colors to be used when filling the slices. |
lcolor |
name of the column with color variable in the links data frame. |
expected |
Should expected coincidences be displayed? |
abline |
adds one or more straight lines between pies. |
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. |
Value
a pieCoin
object.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Hair by Eye by Sex table from M. Friendly (2000)
data(HairEyeColor)
H<-as.data.frame(HairEyeColor)
W<-H$Freq
I<-dichotomize(H,c("Hair","Eye","Sex"),add=FALSE)
C <- coin(I,w=W)
pie <- pieCoin(C)
## Not run:
plot(pie)
## End(Not run)
Express Coin Entries as Fraction of Marginal Table
Description
This is like 'prop.table' for 'coin' objects.
Usage
propCoin(x, margin= 0, decimals=1)
Arguments
x |
'coin' object. |
margin |
index, or vector of indices to generate margin for. |
decimals |
integer indicating the number of decimal places to be used. |
Value
Table like 'x' expressed relative to 'margin'.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Random incidence matrix: 25 scenarios, 4 events.
I <- matrix(rbinom(100, 1, .5), nrow = 25, ncol = 4,
dimnames = list(NULL, c("A", "B", "C", "D")))
C <- coin(I, sort = TRUE)
propCoin(C, 1)
Create an html list of links.
Description
Create an html list of links.
Usage
renderLinks(data, columns, labels = NULL, target = "_blank", sites = NULL)
Arguments
data |
data frame which contains the data. |
columns |
column name which contains the urls. |
labels |
column name which contains the text to display. |
target |
The target attribute specifies where to open the linked document: '_blank' opens the linked document in a new window or tab; '_self' opens the linked document in the same frame as it was clicked; framename opens the linked document in the named iframe. |
sites |
A data frame of 3 columns (url, name, icon) with the sites that the function will recognize. |
Value
a character vector of html formatted links.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
links <- data.frame(name = c(
"Camarhynchus psitticula",
"Camarhynchus pauper",
"Camarhynchus parvulus"
), wikipedia=c(
"https://en.wikipedia.org/wiki/Large_tree_finch",
"https://en.wikipedia.org/wiki/Medium_tree_finch",
"https://en.wikipedia.org/wiki/Small_tree_finch"
),wikidata=c(
"https://www.wikidata.org/wiki/Q578835",
"https://www.wikidata.org/wiki/Q1125857",
"https://www.wikidata.org/wiki/Q1086136"
))
html <- renderLinks(links,c("wikipedia","wikidata"))
Save a netCoin object as a .graphml file to be read in Gephi, Pajek, ...
Description
saveGhml
produces a .graphml file from a netCoin object.
Usage
saveGhml(net, file="netCoin.graphml")
Arguments
net |
A netCoin object. |
file |
The name of the file. If not extension, .gexf is used as default. |
Value
The function creates a file with vertices and arcs or edges of a netCoin object.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Not run:
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", add=FALSE, sep = "; ")
graph <- allNet(data, maxL=.5) # graph from an incidence matrix
saveGhml(graph,"graph") # save graph.net file
## End(Not run)
Save a netCoin object as a .net (.paj) file to be read in Pajek, Gephi, ...
Description
savePajek
produces a .net (.paj) file from a netCoin object.
Usage
savePajek(net, file="file.net", arcs=NULL, edges=NULL,
partitions=NULL, vectors=NULL)
Arguments
net |
a netCoin object. |
file |
The name of the file without extension. It will be .net or .paj acoording to data. The default is file.net or file.paj |
arcs |
Names of netCoin$links to be included and considered as arcs in the Pajek file.. |
edges |
Names of netCoin$links to be included and considered as edges in the Pajek file.. |
partitions |
Names of netCoin$nodes to be included and considered as partitions in the Pajek file. |
vectors |
Names of netCoin$nodes to be included and considered as vectors in the Pajek file. |
Value
The function creates a file with vertices and arcs or edges of a netCoin objetct. Vectors and partitions can be also included. .
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Not run:
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", add=FALSE, sep = "; ")
graph <- allNet(data) # graph from an incidence matrix
savePajek(graph,"graph",edges="Haberman") # save graph.net file
## End(Not run)
Include netCoin Plots in Shiny.
Description
Load a netCoin plot to display in shiny.
Usage
shinyCoin(x)
Arguments
x |
is a |
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
## Not run:
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep="; ")[2:4]
C <- coin(data) # coincidence matrix
N <- asNodes(C) # node data frame
E <- edgeList(C) # edge data frame
net <- netCoin(N, E) # netCoin object
shinyCoin(net)
## End(Not run)
Similarity matrix.
Description
It calculates a similarity/distance matrix from either an incidence data frame/matrix or a coin object.
Usage
sim(input, procedures="Jaccard", level=.95, distance=FALSE,
minimum=1, maximum=Inf, sort=FALSE, decreasing=FALSE,
weight = NULL, pairwise = FALSE)
Arguments
input |
a binary data frame or a coin object, let's say an R list composed by a number of scenarios ( |
procedures |
a vector of statistics of similarity. See details below. |
level |
confidence level |
distance |
convert the similarity matrix into a distance matrix |
minimum |
minimum frequency to obtain a similarity/distance measure. |
maximum |
maxium frequency to obtain a similarity/distance measure. |
sort |
sort the list according to the values of a statistic. See details below |
decreasing |
order in a decreasing way. |
weight |
a vector of weights. Optimal for data.framed tables |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
Details
Possible measures in procedures are
Frequencies (f), Relative frequencies (x), Conditional frequencies (i), Coincidence degree (cc), Probable degree (cp),
Expected (e), Confidence interval (con)
Matching (m), Rogers & Tanimoto (t), Gower (g), Sneath (s), Anderberg (and),
Jaccard (j), Dice (d), antiDice (a), Ochiai (o), Kulczynski (k),
Hamann (ham), Yule (y), Pearson (p), odds ratio (od), Rusell (r),
Haberman (h), Z value of Haberman (z).
Hypergeometric p greater value (hyp).
Value
A similarity/distance matrix.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# From a random incidence matrix I(25X4)
I<-matrix(rbinom(100,1,.5),nrow=25,ncol=4,
dimnames=list(NULL,c("A","B","C","D")))
sim(I)
#Same results
C<-coin(I)
sim(C)
Data: Classical sociologists.
Description
Data frame with names, birth and death year data, birth country and movement.
Usage
data("sociologists")
Format
A data frame with life's period of 16 sociologists and the following 11 variables to study time coincidences:
name
: name and last name of the sociologist.
birth
: birth year.
death
: death year.
birth_place
: birth place.
birth_country
: birth country.
death_place
: death place.
death_country
: death country.
label
: combination of name, birth and death dates.
generation
: generation (every 25 years) of the sociologists.
school
: school of thought.
picture
: name of the file where their picture is.
Source
Own elaboration from manuals of sociology.
References
See events.
Examples
data(sociologists)
head(sociologists, 10)
tail(sociologists, 10)
Networked coincidences from a data frame.
Description
surCoin
produces a network object of coincidences from a data frame converting variables into dichotomies.
Usage
surCoin(data,variables=names(data), commonlabel=NULL,
dichotomies=NULL, valueDicho=1, metric=NULL, exogenous=NULL,
weight=NULL, subsample=FALSE, pairwise=FALSE,
minimum=1, maximum=nrow(data), sort=FALSE, decreasing=TRUE,
frequency=FALSE, percentages=TRUE,
procedures="Haberman", criteria="Z", Bonferroni=FALSE,
support=-Inf, minL=-Inf, maxL=Inf,
directed=FALSE, diagonal=FALSE, sortL=NULL, decreasingL=TRUE,
igraph=FALSE, coin=FALSE, dir=NULL, ...)
Arguments
data |
a data frame. |
variables |
a vector of variables included in the previous data frame. |
commonlabel |
a vector of variables whose names are to be included in nodes labels. |
dichotomies |
a vector of dichotomous variables to appear as just one category. |
valueDicho |
value or values to be selected for dichotomous variables. Default is 1. |
metric |
a vector of metrics. |
exogenous |
a vector of variables whose relations amongst them are of no interest. None by default. |
weight |
a vector of weights. Optimal for data.framed tables. |
subsample |
retrict the analysis to scenarios with at least one event. |
pairwise |
Pairwise mode of handling missing values if TRUE. Listwise by default. |
minimum |
minimum frequency to be considered. |
maximum |
maximum frequency to be considered. |
sort |
sort the coincidence matrix according to frequency of events. |
decreasing |
decreasing or increasing sort of the matrix. |
frequency |
a logical value true if frequencies are to be shown. Default=FALSE. |
percentages |
a logical value true if percentages are to be shown. Default=TRUE. |
procedures |
a vector of statistics of similarity. See below. |
criteria |
statistic to be use for selection criteria. |
Bonferroni |
Bonferroni criterium of the signification test. |
support |
minimum value of the frequency of the coincidence to be edged. |
minL |
minimum value of the statistic to include the edge in the list. |
maxL |
maximum value of the statistic to include the edge in the list. By default is +Inf, except if criteria="Z" or criteria="hyp", in which case it is .5. It is recommnended to change it to .05 if data has been sampled. |
directed |
includes same edges only once. |
diagonal |
includes auto-links. |
sortL |
sort the list according to the values of a statistic. See below. |
decreasingL |
order in a decreasing way. |
igraph |
Produces an igraph object instead of a netCoin object if TRUE. |
coin |
Only return the coincidences matrix if TRUE. |
dir |
a "character" string representing the directory where the web files will be saved. |
... |
Any netCoin argument. |
Details
Possible measures in procedures are
Frequencies (f), Relative frequencies (x), Conditional frequencies (i), Coincidence degree (cc), Probable degree (cp),
Expected (e), Confidence interval (con)
Matching (m), Rogers & Tanimoto (t), Gower (g), Sneath (s), Anderberg (and),
Jaccard (j), Dice (d), antiDice (a), Ochiai (o), Kulczynski (k),
Hamann (ham), Yule (y), Pearson (p), odds ratio (od), Rusell (r),
Haberman (h), Z value of Haberman (z),
Hypergeometric p greater value (hyp).
Convert a matrix into an edge list (shape).
Value
This function creates a netCoin object (or igraph) and, if stated, 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# A data frame with two variables Gender and Opinion
frame <- data.frame(Gender=c(rep("Man",3),rep("Woman",3)),
Opinion=c("Yes","Yes","No","No","No","Yes"))
surCoin(frame,commonlabel="") # network object
# A data frame with two variables (Gender and Hand) and nodes
input <- data.frame(
Gender = c("Women", "Men", "Men", "Women", "Women","Men",
"Men", "Men", "Women", "Women", "Men", "Women"),
Hand = c("Right", "Left","Right", "Right", "Right", "Right",
"Left", "Right", "Right", "Left","Right", "Right"))
nodes <- data.frame(
name = c("Gender:Men","Gender:Women", "Hand:Left", "Hand:Right"),
label = c("Women(50\u25)","Men(50\u25)",
"Left hand(25\u25)", "Right hand(75\u25)"))
G <- surCoin(input, nodes=nodes, proc=c("h","i"), label="label",
ltext="i", showArrows=TRUE, maxL=.99)
Networked coincidences from a data frame.
Description
surScat
produces a network object of coincidences from a data frame converting variables into dichotomies.
Usage
surScat(data, variables=names(data), active=variables, type=c("mca", "pca"), nclusters=2,
maxN=2000, ...)
Arguments
data |
a data frame. |
variables |
a vector of variables included in the previous data frame. |
active |
a vector of variables actived in the previous data frame. |
type |
Factorial type: mca for qualitative active variables, pca for quantitative active variables. |
nclusters |
number of clusters. |
maxN |
Maximum number or rows. |
... |
Any netCoin argument. |
Details
Possible measures in procedures are
Frequencies (f), Relative frequencies (x), Conditional frequencies (i), Coincidence degree (cc), Probable degree (cp),
Expected (e), Confidence interval (con)
Matching (m), Rogers & Tanimoto (t), Gower (g), Sneath (s), Anderberg (and),
Jaccard (j), Dice (d), antiDice (a), Ochiai (o), Kulczynski (k),
Hamann (ham), Yule (y), Pearson (p), odds ratio (od), Rusell (r),
Haberman (h), Z value of Haberman (z),
Hypergeometric p greater value (hyp).
Convert a matrix into an edge list (shape).
Value
This function creates a netCoin object (or igraph) and, if stated, 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.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
References
Escobar, M. and Martinez-Uribe, L. (2020)
Network Coincidence Analysis: The netCoin
R
Package.
Journal of Statistical Software, 93, 1-32.
doi:10.18637/jss.v093.i11.
Examples
# A data frame with two variables Gender and Opinion
frame<-data.frame(Gender=c(rep("Man",3),rep("Woman",3)),
Opinion=c("Yes","Yes","No","No","No","Yes"))
surScat(frame) # network object
Networked coincidences.
Description
timeCoin
produces a timeCoin object.
Usage
timeCoin(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)
Arguments
periods |
a data frame with at least three vectors of name, start and end of the periods. |
name |
name of the vector with names in the periods data frame. |
start |
name of the vector with starts in the periods data frame. |
end |
name of the vector with ends in the periods data frame. |
group |
name of the vector with groups in the periods data frame. |
text |
name of the vector with html text in the periods data frame. |
main |
upper title of the graph. |
note |
lower title of the graph. |
info |
name of the vector with information to display in a panel in the periods data frame. |
events |
a data frame of events included into the periods with three columns: event name, periodParent and eventTime |
eventNames |
name of the vector with names in the events data frame. |
eventPeriod |
name of the vector with period names in the events data frame. |
eventTime |
name of the vector with time points in the events data frame. |
eventColor |
name of the vector with color criteria in the events data frame. |
eventShape |
name of the vector with shape criteria in the events data frame. |
cex |
number indicating the amount by which plotting text should be scaled relative to the default. Default = 1. |
language |
a character vector (es=spanish; en=english; ca=catalan). |
dir |
a "character" string representing the directory where the web files will be saved. |
Value
Object of class timeCoin
.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# Database of the classical sociologists.
# Only periods
data(sociologists)
timeCoin(sociologists, "name", "birth", "death", "school")
# Periods and events
data(works)
timeCoin(sociologists, "name", "birth", "death", "school",
events=works, eventNames="label", eventPeriod="author", eventTime="date")
igraph object.
Description
igraph
object from a netCoin
object.
Usage
toIgraph(net)
Arguments
net |
is a |
Value
An igraph
object.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Examples
# A character column (with separator)
frame <- data.frame(A = c("Man; Women", "Women; Women",
"Man; Man", "Undet.; Women; Man"))
data <- dichotomize(frame, "A", sep = "; ")[2:4]
C <- coin(data) # coincidence matrix
N <- asNodes(C) # node data frame
E <- edgeList(C)
net <- netCoin(N, E)
toIgraph(net) # conversion into a igraph object
Data: Classical sociological works.
Description
Data frame with classical sociological works writen by authors in the sociologists data frame.
Usage
data("sociologists")
Format
A data frame with 54 observations (events) and the following 4 variables to study coincidences in time:
name
: name and last name of the author of the work.
label
: abbreviation of the complete name.
works
: work's name.
date
: year of its first publication.
Author(s)
Modesto Escobar, Department of Sociology and Communication, University of Salamanca. See https://sociocav.usal.es/blog/modesto-escobar/
Source
Own elaboration from manuals of sociology.
References
See events.
Examples
data(works)
head(works, 10)
tail(works, 10)