R/graphSNA.R

#' Visualization of SNA parameters
#'
#' This function is used to produce dynamic graphs
#' illustrating the role of different localities in the network
#' based on mobility parameters generated by the Network Analysis (SNA).
#'
#' Cette fonction sert à produire des graphiques dynamiques
#' illustrant le rôle des différentes localités dans le réseau en fonction des
#' paramètres de mobilité issus de l'analyse de réseau (SNA)
#'
#' @import ggplot2
#' @importFrom plotly ggplotly
#' @export graphSNA
#' @param x the data.frame containing the names of localities, mobility parameters and GPS coordinates. \cr
#' FR: data.frame contenant les noms des localités, les paramètres de mobilité et les coordonnées GPS.
#' @param indegree the column containing the "indegree" parameters, will be plotted as the x -coordinate.
#' @param outdegree the column containing the "outdegree" parameters, will be plotted as the x -coordinate.
#' @param betweeness the column containing the "betweeness" parameters, will define the size of the dots.
#' @param NOM  the column containing the names of the localities.
#' @keywords plot ggplot sna network
graphSNA <- function(x, indegree, outdegree, betweeness, NOM){
  x <- x[x$degree != 0,]

  message("Place your cursor on the dots to access details (location name, parameters values)."," ","Placez votre curseur sur les points pour voir \xe0 quelle localisation ils correspondent.")

 ggplotly(
    ggplot(x, aes(indegree, outdegree,label=NOM)) +
      geom_point(aes(size = betweeness)) +
      xlab("Degre entrant") +
      ylab("Degre sortant") +
      scale_size_continuous(name = "Centralite d'intermediarite") +
      ggtitle("Localites du reseau de mobilite animale representees\nen fonction de leur degre entrant et de leur degre sortant") +
      theme(plot.title = element_text(hjust = 0.5)))

}
Pachka/AQCR_SNA_Package documentation built on May 11, 2019, 7:26 p.m.