diff --git a/.Rbuildignore b/.Rbuildignore index 0a707e2..a474ca3 100755 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ +^Meta$ ^.*\.Rproj$ ^\.Rproj\.user$ ^data-raw$ diff --git a/.gitignore b/.gitignore index 26678ba..8a137da 100755 --- a/.gitignore +++ b/.gitignore @@ -1,28 +1,24 @@ +Meta +doc .Rproj.user .Rhistory .RData inst/doc - # Binary files *.so *.o *.xls* *.doc* *.ppt* - *.ods - *.zip *.gz *.tar - # Tempfiles *.dta -*.ods *.log *.out *.tex - playground/ doc/ diff --git a/DESCRIPTION b/DESCRIPTION index 2878f57..c4c19dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: netdiffuseR Title: Analysis of Diffusion and Contagion Processes on Networks -Version: 1.20.0 -Date: 2018-06-06 +Version: 1.20.1 +Date: 2019-03-22 Authors@R: c( person("George", "Vega Yon", email="g.vegayon@gmail.com", role=c("aut", "cre"), comment=c(ORCID = "0000-0002-3171-0844", what="Rewrite functions with Rcpp, plus new features") @@ -39,7 +39,7 @@ Imports: utils, boot, igraph, - viridis + viridisLite Suggests: covr, testthat, @@ -49,7 +49,7 @@ Suggests: survival VignetteBuilder: knitr LinkingTo: Rcpp, RcppArmadillo -RoxygenNote: 6.0.1.9000 +RoxygenNote: 6.1.1 Encoding: UTF-8 URL: https://github.com/USCCANA/netdiffuseR, https://USCCANA.github.io/netdiffuseR diff --git a/NAMESPACE b/NAMESPACE index 1e9ecd7..6805d22 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -250,6 +250,8 @@ importFrom(stats,var) importFrom(utils,getFromNamespace) importFrom(utils,head) importFrom(utils,str) -importFrom(viridis,viridis_pal) +importFrom(viridisLite,inferno) +importFrom(viridisLite,magma) +importFrom(viridisLite,viridis) importMethodsFrom(Matrix,t) useDynLib(netdiffuseR, .registration = TRUE) diff --git a/NEWS.md b/NEWS.md index ec40063..ade1033 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,17 @@ +# Changes in netdiffuseR version 1.20.1 (2019-03-22) + +* This version has no user level visible changes. + +## Other changes + +* Changing `PI` macros in C++ code as requested by RcppCore. + +* Setting 3.5 seed version for tests so that test won't break following message + from CRAN. + + + + # Changes in netdiffuseR version 1.20.0 (2018-06-06) ## New functions and features diff --git a/R/diffnet-methods.r b/R/diffnet-methods.r index 8a312c4..041003f 100644 --- a/R/diffnet-methods.r +++ b/R/diffnet-methods.r @@ -957,7 +957,7 @@ plot_infectsuscep <- function( xlab = "Infectiousness of ego", ylab = "Susceptibility of ego", sub = ifelse(logscale, "(in log-scale)", NA), - color.palette = viridis::viridis_pal(), + color.palette = function(n) viridisLite::viridis(n), include.grid = TRUE, exclude.zeros = FALSE, valued = getOption("diffnet.valued",FALSE), diff --git a/R/imports.r b/R/imports.r index a4d64ab..1700f6e 100644 --- a/R/imports.r +++ b/R/imports.r @@ -8,7 +8,7 @@ NULL #' @importFrom network as.edgelist is.multiplex is.directed has.loops as.network #' get.network.attribute list.vertex.attributes #' @importFrom networkDynamic networkDynamic network.extract network.collapse -#' @importFrom viridis viridis_pal +#' @importFrom viridisLite viridis inferno magma NULL #' @useDynLib netdiffuseR, .registration = TRUE diff --git a/R/misc.r b/R/misc.r index c575f04..9ea5a67 100644 --- a/R/misc.r +++ b/R/misc.r @@ -132,7 +132,7 @@ drawColorKey <- function( key.pos = c(.925,.975,.05,.95), pos = 2, nlevels = length(tick.marks), - color.palette = viridis::viridis(nlevels), + color.palette = viridisLite::viridis(nlevels), tick.width = c(.01,.0075), add.box = TRUE, na.col = NULL, diff --git a/R/plot_diffnet2.r b/R/plot_diffnet2.r index 52d8960..e8c153d 100644 --- a/R/plot_diffnet2.r +++ b/R/plot_diffnet2.r @@ -95,7 +95,7 @@ plot_diffnet2.default <- function( graph, toa, pers = min(toa, na.rm = TRUE):max(toa, na.rm = TRUE), - color.ramp = grDevices::colorRamp(viridis::magma(20)), + color.ramp = grDevices::colorRamp(viridisLite::magma(20)), layout = NULL, key.width = 0.1, key.args = list(), diff --git a/README.Rmd b/README.Rmd index 1fef067..934c106 100644 --- a/README.Rmd +++ b/README.Rmd @@ -163,7 +163,7 @@ data("medInnovationsDiffNet") set.seed(131) plot_threshold( medInnovationsDiffNet, - vertex.color = viridis::inferno(4)[medInnovationsDiffNet[["city"]]], + vertex.color = viridisLite::inferno(4)[medInnovationsDiffNet[["city"]]], vertex.sides = medInnovationsDiffNet[["city"]] + 2, sub = "Note: Vertices' sizes and shapes given by degree and city respectively", jitter.factor = c(1,1), jitter.amount = c(.25,.025) @@ -215,7 +215,7 @@ diffnet.toa(x) <- sample(x$toa, size = nnodes(x)) dm1 <- diffusionMap(x, layout = dm0$coords, kde2d.args=list(n=150, h=.5)) oldpar <- par(no.readonly = TRUE) -col <- viridis::plasma(100) +col <- viridisLite::plasma(100) par(mfrow=c(1,2), oma=c(1,0,0,0), cex=.8) image(dm0, col=col, main="Non-random Times of Adoption\nAdoption from the core.") image(dm1, col=col, main="Random Times of Adoption") @@ -234,11 +234,11 @@ ftable(out) # Plotting oldpar <- par(no.readonly = TRUE) par(xpd=TRUE) -plot(out, color=viridis::inferno(5), las = 2, xlab="Time of Adoption", +plot(out, color=viridisLite::inferno(5), las = 2, xlab="Time of Adoption", ylab="Threshold", main="") # Adding key -legend("bottom", legend = levels(out$thr), fill=viridis::inferno(5), horiz = TRUE, +legend("bottom", legend = levels(out$thr), fill=viridisLite::inferno(5), horiz = TRUE, cex=.6, bty="n", inset=c(0,-.1)) par(oldpar) ``` diff --git a/README.md b/README.md index da871aa..7c7e744 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,64 @@ netdiffuseR: Analysis of Diffusion and Contagion Processes on Networks ================ -[![Build Status](https://travis-ci.org/USCCANA/netdiffuseR.svg?branch=master)](https://travis-ci.org/USCCANA/netdiffuseR) [![Build status](https://ci.appveyor.com/api/projects/status/6u48wgl1lqak2jum?svg=true)](https://ci.appveyor.com/project/gvegayon/netdiffuser) [![codecov.io](https://codecov.io/github/USCCANA/netdiffuseR/coverage.svg?branch=master)](https://codecov.io/github/USCCANA/netdiffuseR?branch=master) [![](http://cranlogs.r-pkg.org/badges/netdiffuseR)](http://cran.rstudio.com/web/packages/netdiffuseR/index.html) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/netdiffuseR)](http://cran.r-project.org/package=netdiffuseR) [![](http://cranlogs.r-pkg.org/badges/grand-total/netdiffuseR)](http://cran.rstudio.com/web/packages/netdiffuseR/index.html) - -This package contains functions useful for analyzing network data for diffusion of innovations applications. - -The package was developed as part of the paper Thomas W. Valente, Stephanie R. Dyal, Kar-Hai Chu, Heather Wipfli, Kayo Fujimoto, *Diffusion of innovations theory applied to global tobacco control treaty ratification*, Social Science & Medicine, Volume 145, November 2015, Pages 89-97, ISSN 0277-9536 (available [here](http://www.sciencedirect.com/science/article/pii/S027795361530143X)) +[![Build +Status](https://travis-ci.org/USCCANA/netdiffuseR.svg?branch=master)](https://travis-ci.org/USCCANA/netdiffuseR) +[![Build +status](https://ci.appveyor.com/api/projects/status/6u48wgl1lqak2jum?svg=true)](https://ci.appveyor.com/project/gvegayon/netdiffuser) +[![codecov.io](https://codecov.io/github/USCCANA/netdiffuseR/coverage.svg?branch=master)](https://codecov.io/github/USCCANA/netdiffuseR?branch=master) +[![](http://cranlogs.r-pkg.org/badges/netdiffuseR)](http://cran.rstudio.com/web/packages/netdiffuseR/index.html) +[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/netdiffuseR)](http://cran.r-project.org/package=netdiffuseR) +[![](http://cranlogs.r-pkg.org/badges/grand-total/netdiffuseR)](http://cran.rstudio.com/web/packages/netdiffuseR/index.html) +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1039317.svg)](https://doi.org/10.5281/zenodo.1039317) + +This package contains functions useful for analyzing network data for +diffusion of innovations applications. + +The package was developed as part of the paper Thomas W. Valente, +Stephanie R. Dyal, Kar-Hai Chu, Heather Wipfli, Kayo Fujimoto, +*Diffusion of innovations theory applied to global tobacco control +treaty ratification*, Social Science & Medicine, Volume 145, November +2015, Pages 89-97, ISSN 0277-9536 (available +[here](http://www.sciencedirect.com/science/article/pii/S027795361530143X)) From the description: -> Empirical statistical analysis, visualization and simulation of diffusion and contagion processes on networks. The package implements algorithms for calculating network diffusion statistics such as transmission rate, hazard rates, exposure models, network threshold levels, infectiousness (contagion), and susceptibility. The package is inspired by work published in Valente, et al., (2015) ; Valente (1995) , Myers (2000) , Iyengar and others (2011) , Burt (1987) ; among others. +> Empirical statistical analysis, visualization and simulation of +> diffusion and contagion processes on networks. The package implements +> algorithms for calculating network diffusion statistics such as +> transmission rate, hazard rates, exposure models, network threshold +> levels, infectiousness (contagion), and susceptibility. The package is +> inspired by work published in Valente, et al., (2015) +> ; Valente (1995) +> , Myers (2000) , Iyengar and +> others (2011) , Burt (1987) +> ; among others. -**Acknowledgements**: netdiffuseR was created with the support of grant R01 CA157577 from the National Cancer Institute/National Institutes of Health. +**Acknowledgements**: netdiffuseR was created with the support of grant +R01 CA157577 from the National Cancer Institute/National Institutes of +Health. -News ----- +## News Changelog can be view [here](NEWS.md). -- \[2016-06-02\] A video of the **netdiffuseR** workshop at SUNBELT 2016 is now online on [youtube](https://www.youtube.com/playlist?list=PLT-GgRN1lFI4coHDqkRJm3flDw9e1gg2P), and the workshop materials can be found [here](https://github.com/USCCANA/netdiffuseR/tree/master/doc/conferences/20160400_sunbelt2016/) -- \[2016-04-11\] **netdiffuseR** will be on [useR! 2016](http://user2016.org) on as a presentation and on [IC2S2 2016](http://www.kellogg.northwestern.edu/news-events/conference/ic2s2/2016.aspx) in the posters session. -- \[2016-03-16\] Next CRAN release scheduled for April 11th 2016 (after the workshop). -- \[2016-02-18\] **netdiffuseR** vers 1.16.2 is now on CRAN! -- \[2016-02-18\] We will be offering a workshop at the 2016 SUNBELT Conference (checkout the full list of workshops [here](http://insna.org/sunbelt2016/program/)). - -Installation ------------- + - \[2016-06-02\] A video of the **netdiffuseR** workshop at SUNBELT + 2016 is now online on + [youtube](https://www.youtube.com/playlist?list=PLT-GgRN1lFI4coHDqkRJm3flDw9e1gg2P), + and the workshop materials can be found + [here](https://github.com/USCCANA/netdiffuseR/tree/master/doc/conferences/20160400_sunbelt2016/) + - \[2016-04-11\] **netdiffuseR** will be on + [useR\! 2016](http://user2016.org) on as a presentation and on + [IC2S2 2016](http://www.kellogg.northwestern.edu/news-events/conference/ic2s2/2016.aspx) + in the posters session. + - \[2016-03-16\] Next CRAN release scheduled for April 11th 2016 + (after the workshop). + - \[2016-02-18\] **netdiffuseR** vers 1.16.2 is now on CRAN\! + - \[2016-02-18\] We will be offering a workshop at the 2016 SUNBELT + Conference (checkout the full list of workshops + [here](http://insna.org/sunbelt2016/program/)). + +## Installation ### CRAN version @@ -37,15 +70,20 @@ install.packages("netdiffuseR") ### Bleeding edge version -If you want the latest (unstable) version of **netdiffuseR**, using the `devtools` package, you can install `netdiffuseR` dev version as follows +If you want the latest (unstable) version of **netdiffuseR**, using the +`devtools` package, you can install `netdiffuseR` dev version as follows ``` r devtools::install_github('USCCANA/netdiffuseR', build_vignettes = TRUE) ``` -You can skip building vignettes by setting `build_vignettes = FALSE` (so it is not required). +You can skip building vignettes by setting `build_vignettes = FALSE` (so +it is not required). -For the case of OSX users, there seems to be a problem when installing packages depending on `Rcpp`. This issue, developed [here](https://github.com/USCCANA/netdiffuseR/issues/3), can be solved by open the terminal and typing the following +For the case of OSX users, there seems to be a problem when installing +packages depending on `Rcpp`. This issue, developed +[here](https://github.com/USCCANA/netdiffuseR/issues/3), can be solved +by open the terminal and typing the following ``` sh curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2 @@ -56,46 +94,52 @@ before installing the package through `devtools`. ### Binary versions -For the case of windows and mac users, they can find binary versions of the package [here](https://github.com/USCCANA/netdiffuseR/releases), netdiffuseR\_1...zip, and netdiffuseR\_1...tgz respectively. They can install this directly as follows (using the 1.16.3.29 version): - -1. Install dependencies from CRAN +For the case of windows and mac users, they can find binary versions of +the package [here](https://github.com/USCCANA/netdiffuseR/releases), +netdiffuseR\_1…zip, and netdiffuseR\_1…tgz respectively. They can +install this directly as follows (using the 1.16.3.29 version): +1. Install dependencies from + CRAN + ``` r > install.packages(c("igraph", "Matrix", "SparseM", "RcppArmadillo", "sna"), dependencies=TRUE) ``` 2. Download the binary version and install it as follows: - + ``` r > install.packages("netdiffuseR_1.16.3.29.zip", repos=NULL) ``` - + For windows users, and for Mac users: - + ``` r > install.packages("netdiffuseR_1.16.3.29.tgz", repos=NULL) ``` -Tutorials ---------- +## Tutorials -Since starting netdiffuseR, we have done a couple of workshops at Sunbelt and NASN. Here are the repositories: +Since starting netdiffuseR, we have done a couple of workshops at +Sunbelt and NASN. Here are the repositories: -- Sunbelt 2018: ([source code](https://github.com/USCCANA/netdiffuser-sunbelt2018)) -- NASN 2017: ([source code](https://github.com/USCCANA/netdiffuser-nasn2017)) -- Sunbelt 2016: + - Sunbelt 2018: + ([source code](https://github.com/USCCANA/netdiffuser-sunbelt2018)) + - NASN 2017: ([source + code](https://github.com/USCCANA/netdiffuser-nasn2017)) + - Sunbelt 2016: -Presentations -------------- +## Presentations -- ic2s2 2016 Evanston, IL: (poster) -- useR! 2016 Stanford, CA: (slides) -- useR! 2016: + - ic2s2 2016 Evanston, IL: + (poster) + - useR\! 2016 Stanford, CA: + (slides) + - useR\! 2016: -Examples --------- +## Examples -This example has been taken from the package's vignettes: +This example has been taken from the package’s vignettes: ``` r library(netdiffuseR) @@ -181,7 +225,7 @@ summary(diffnet) out <- plot_infectsuscep(diffnet, bins = 20,K=5, logscale = FALSE, h=.01) ``` -![](README_files/figure-markdown_github/plot_infectsuscept-1.png) +![](README_files/figure-gfm/plot_infectsuscept-1.png) ``` r out <- plot_infectsuscep(diffnet, bins = 20,K=5, logscale = TRUE, @@ -191,7 +235,7 @@ out <- plot_infectsuscep(diffnet, bins = 20,K=5, logscale = TRUE, ## Warning in plot_infectsuscep.list(graph$graph, graph$toa, t0, normalize, : ## When applying logscale some observations are missing. -![](README_files/figure-markdown_github/plot_infectsuscept-2.png) +![](README_files/figure-gfm/plot_infectsuscept-2.png) ### Threshold @@ -220,7 +264,7 @@ diffnet plot_threshold(diffnet) ``` -![](README_files/figure-markdown_github/BoringThreshold,%20plot_threshold-1.png) +![](README_files/figure-gfm/BoringThreshold,%20plot_threshold-1.png) Using more features @@ -229,7 +273,7 @@ data("medInnovationsDiffNet") set.seed(131) plot_threshold( medInnovationsDiffNet, - vertex.color = viridis::inferno(4)[medInnovationsDiffNet[["city"]]], + vertex.color = viridisLite::inferno(4)[medInnovationsDiffNet[["city"]]], vertex.sides = medInnovationsDiffNet[["city"]] + 2, sub = "Note: Vertices' sizes and shapes given by degree and city respectively", jitter.factor = c(1,1), jitter.amount = c(.25,.025) @@ -239,7 +283,7 @@ plot_threshold( ## Warning in (function (graph, expo, toa, include_censored = FALSE, t0 = ## min(toa, : -vertex.sides- will be coerced to integer. -![](README_files/figure-markdown_github/NiceThreshold-1.png) +![](README_files/figure-gfm/NiceThreshold-1.png) ### Adoption rate @@ -247,7 +291,7 @@ plot_threshold( plot_adopters(diffnet) ``` -![](README_files/figure-markdown_github/Adopters-1.png) +![](README_files/figure-gfm/Adopters-1.png) ### Hazard rate @@ -255,7 +299,7 @@ plot_adopters(diffnet) hazard_rate(diffnet) ``` -![](README_files/figure-markdown_github/Hazard-1.png) +![](README_files/figure-gfm/Hazard-1.png) ### Diffusion process @@ -263,14 +307,14 @@ hazard_rate(diffnet) plot_diffnet(medInnovationsDiffNet, slices=c(1,9,8)) ``` -![](README_files/figure-markdown_github/plot_diffnet-1.png) +![](README_files/figure-gfm/plot_diffnet-1.png) ``` r diffnet.toa(brfarmersDiffNet)[brfarmersDiffNet$toa >= 1965] <- NA plot_diffnet2(brfarmersDiffNet, vertex.size = "indegree") ``` -![](README_files/figure-markdown_github/plot_diffnet2-1.png) +![](README_files/figure-gfm/plot_diffnet2-1.png) ``` r set.seed(1231) @@ -291,7 +335,7 @@ diffnet.toa(x) <- sample(x$toa, size = nnodes(x)) dm1 <- diffusionMap(x, layout = dm0$coords, kde2d.args=list(n=150, h=.5)) oldpar <- par(no.readonly = TRUE) -col <- viridis::plasma(100) +col <- viridisLite::plasma(100) par(mfrow=c(1,2), oma=c(1,0,0,0), cex=.8) image(dm0, col=col, main="Non-random Times of Adoption\nAdoption from the core.") image(dm1, col=col, main="Random Times of Adoption") @@ -300,7 +344,7 @@ mtext("Both networks have the same distribution on times of adoption", 1, outer = TRUE) ``` -![](README_files/figure-markdown_github/plot_diffnet2%20with%20map-1.png) +![](README_files/figure-gfm/plot_diffnet2%20with%20map-1.png) ``` r par(oldpar) @@ -325,15 +369,15 @@ ftable(out) # Plotting oldpar <- par(no.readonly = TRUE) par(xpd=TRUE) -plot(out, color=viridis::inferno(5), las = 2, xlab="Time of Adoption", +plot(out, color=viridisLite::inferno(5), las = 2, xlab="Time of Adoption", ylab="Threshold", main="") # Adding key -legend("bottom", legend = levels(out$thr), fill=viridis::inferno(5), horiz = TRUE, +legend("bottom", legend = levels(out$thr), fill=viridisLite::inferno(5), horiz = TRUE, cex=.6, bty="n", inset=c(0,-.1)) ``` -![](README_files/figure-markdown_github/mosaic-1.png) +![](README_files/figure-gfm/mosaic-1.png) ``` r par(oldpar) @@ -345,9 +389,9 @@ par(oldpar) sessionInfo() ``` - ## R version 3.4.4 (2018-03-15) + ## R version 3.5.3 (2019-03-11) ## Platform: x86_64-pc-linux-gnu (64-bit) - ## Running under: Ubuntu 16.04.4 LTS + ## Running under: Ubuntu 16.04.6 LTS ## ## Matrix products: default ## BLAS: /usr/lib/libblas/libblas.so.3.6.0 @@ -365,39 +409,45 @@ sessionInfo() ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: - ## [1] netdiffuseR_1.19.999 + ## [1] netdiffuseR_1.20.0 ## ## loaded via a namespace (and not attached): - ## [1] igraph_1.2.1 Rcpp_0.12.17 knitr_1.20 + ## [1] igraph_1.2.2 Rcpp_1.0.0 knitr_1.21 ## [4] magrittr_1.5 network_1.13.0.1 networkDynamic_0.9.0 - ## [7] MASS_7.3-50 munsell_0.4.3 viridisLite_0.3.0 - ## [10] colorspace_1.3-2 lattice_0.20-35 rlang_0.2.1 - ## [13] plyr_1.8.4 stringr_1.3.1 tools_3.4.4 - ## [16] MatchIt_3.0.2 grid_3.4.4 gtable_0.2.0 - ## [19] sna_2.4 coda_0.19-1 htmltools_0.3.6 - ## [22] lazyeval_0.2.1 yaml_2.1.19 rprojroot_1.3-2 - ## [25] digest_0.6.15 tibble_1.4.2 Matrix_1.2-14 - ## [28] gridExtra_2.3 ggplot2_2.2.1 viridis_0.5.1 - ## [31] evaluate_0.10.1 rmarkdown_1.9 statnet.common_4.1.2 - ## [34] stringi_1.2.2 pillar_1.2.3 compiler_3.4.4 - ## [37] scales_0.5.0 backports_1.1.2 boot_1.3-20 - ## [40] SparseM_1.77 pkgconfig_2.0.1 - -To-do list ----------- - -- Import/Export functions for interfacing other package's clases, in particular: `statnet` set (specially the packages `networkDynamic` and `ndtv`), ~~`igraph`~~ and `Rsiena`. -- Populate the tests folder. -- ~~Use spells? (`select_egoalter` would use this)~~ -- ~~Classify individuals by adoption category using early adopters, adopters, and laggards, and by threshold using very low, low, high and very high threshold (Valente 95' p. 94).~~ -- ~~Double check all functions using adjacency matrix values.~~ -- ~~Remove dimnames from matrices and vectors. It is more efficient to use the ones stored in meta instead.~~ -- Implement the Bass model -- ~~Include function to import survey data (as shown on the vignettes)~~ -- Exposure based on Mahalanobis distances and also Roger Leenders on weighting exposure (internal note). -- (2016-03-30): use `xspline` for drawing polygons & edges. -- ~~(2016-04-04): Add more options to `exposure`, namely, `self` (so removes diagonal or not!).~~ -- (2016-04-19): animal behaviorists. -- (2016-10-18): Review language throughout the manual (more than innovation). -- (2016-10-18): Evaluate and eventually use a standard graph format (`network` for instance?). -- (2016-10-18): Standarize graph plot methods (choose either statnet/igraph/own) + ## [7] MASS_7.3-51.1 viridisLite_0.3.0 lattice_0.20-38 + ## [10] stringr_1.3.1 tools_3.5.3 MatchIt_3.0.2 + ## [13] grid_3.5.3 xfun_0.4 sna_2.4 + ## [16] coda_0.19-2 htmltools_0.3.6 yaml_2.2.0 + ## [19] digest_0.6.18 Matrix_1.2-16 evaluate_0.12 + ## [22] rmarkdown_1.11 statnet.common_4.1.4 stringi_1.2.4 + ## [25] compiler_3.5.3 boot_1.3-20 SparseM_1.77 + ## [28] pkgconfig_2.0.2 + +## To-do list + + - Import/Export functions for interfacing other package’s clases, in + particular: `statnet` set (specially the packages `networkDynamic` + and `ndtv`), ~~`igraph`~~ and `Rsiena`. + - Populate the tests folder. + - ~~Use spells? (`select_egoalter` would use this)~~ + - ~~Classify individuals by adoption category using early adopters, + adopters, and laggards, and by threshold using very low, low, high + and very high threshold (Valente 95’ p. 94).~~ + - ~~Double check all functions using adjacency matrix values.~~ + - ~~Remove dimnames from matrices and vectors. It is more efficient to + use the ones stored in meta instead.~~ + - Implement the Bass model + - ~~Include function to import survey data (as shown on the + vignettes)~~ + - Exposure based on Mahalanobis distances and also Roger Leenders on + weighting exposure (internal note). + - (2016-03-30): use `xspline` for drawing polygons & edges. + - ~~(2016-04-04): Add more options to `exposure`, namely, `self` (so + removes diagonal or not\!).~~ + - (2016-04-19): animal behaviorists. + - (2016-10-18): Review language throughout the manual (more than + innovation). + - (2016-10-18): Evaluate and eventually use a standard graph format + (`network` for instance?). + - (2016-10-18): Standarize graph plot methods (choose either + statnet/igraph/own) diff --git a/README_files/figure-gfm/Adopters-1.png b/README_files/figure-gfm/Adopters-1.png new file mode 100644 index 0000000..3f1f912 Binary files /dev/null and b/README_files/figure-gfm/Adopters-1.png differ diff --git a/README_files/figure-gfm/BoringThreshold, plot_threshold-1.png b/README_files/figure-gfm/BoringThreshold, plot_threshold-1.png new file mode 100644 index 0000000..4acb7ef Binary files /dev/null and b/README_files/figure-gfm/BoringThreshold, plot_threshold-1.png differ diff --git a/README_files/figure-gfm/Hazard-1.png b/README_files/figure-gfm/Hazard-1.png new file mode 100644 index 0000000..7220431 Binary files /dev/null and b/README_files/figure-gfm/Hazard-1.png differ diff --git a/README_files/figure-gfm/NiceThreshold-1.png b/README_files/figure-gfm/NiceThreshold-1.png new file mode 100644 index 0000000..274f3de Binary files /dev/null and b/README_files/figure-gfm/NiceThreshold-1.png differ diff --git a/README_files/figure-gfm/mosaic-1.png b/README_files/figure-gfm/mosaic-1.png new file mode 100644 index 0000000..3fcc476 Binary files /dev/null and b/README_files/figure-gfm/mosaic-1.png differ diff --git a/README_files/figure-gfm/plot_diffnet-1.png b/README_files/figure-gfm/plot_diffnet-1.png new file mode 100644 index 0000000..4d230d3 Binary files /dev/null and b/README_files/figure-gfm/plot_diffnet-1.png differ diff --git a/README_files/figure-gfm/plot_diffnet2 with map-1.png b/README_files/figure-gfm/plot_diffnet2 with map-1.png new file mode 100644 index 0000000..5226bc5 Binary files /dev/null and b/README_files/figure-gfm/plot_diffnet2 with map-1.png differ diff --git a/README_files/figure-gfm/plot_diffnet2-1.png b/README_files/figure-gfm/plot_diffnet2-1.png new file mode 100644 index 0000000..a501339 Binary files /dev/null and b/README_files/figure-gfm/plot_diffnet2-1.png differ diff --git a/README_files/figure-gfm/plot_infectsuscept-1.png b/README_files/figure-gfm/plot_infectsuscept-1.png new file mode 100644 index 0000000..5f15a7f Binary files /dev/null and b/README_files/figure-gfm/plot_infectsuscept-1.png differ diff --git a/README_files/figure-gfm/plot_infectsuscept-2.png b/README_files/figure-gfm/plot_infectsuscept-2.png new file mode 100644 index 0000000..c28d60b Binary files /dev/null and b/README_files/figure-gfm/plot_infectsuscept-2.png differ diff --git a/inst/CITATION b/inst/CITATION index 84b3e4a..2f40e62 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -5,7 +5,7 @@ bibentry(bibtype = "Manual", title = "{{netdiffuseR: Analysis of Diffusion and Contagion Processes on Networks}}", author = c( person("George", "Vega Yon", comment = c(ORCID = "0000-0002-3171-0844")), - person("Thomas", "Valente") + person("Thomas", "Valente", comment=c(ORCID="0000-0002-8824-5816")) ), year = year, note = note, diff --git a/inst/NEWS b/inst/NEWS index 77066dc..287914c 100644 --- a/inst/NEWS +++ b/inst/NEWS @@ -1,5 +1,20 @@ +CHANGES IN NETDIFFUSER VERSION 1.20.1 (2019-03-22) + + +- This version has no user level visible changes. + + +Other changes + +- Changing PI macros in C++ code as requested by RcppCore. + +- Setting 3.5 seed version for tests so that test won’t break + following message from CRAN. + + + CHANGES IN NETDIFFUSER VERSION 1.20.0 (2018-06-06) @@ -41,9 +56,9 @@ New functions and features diffusion instead of returning with error. - plot.diffnet, plot_diffnet, plot.diffnet_mentor, and plot_diffnet2 - use igraph for plotting. Also, users can now pass "degree" for + use igraph for plotting. Also, users can now pass “degree” for -vertex.size- (vertex.cex not used anymore), allowing to - "automatically" scale vertices by (in/out/.)degree. Also, plotting + “automatically” scale vertices by (in/out/.)degree. Also, plotting arguments like vertex.* or edge.* are standarized so these match igraph. @@ -83,9 +98,9 @@ Other changes - plot_diffnet function now has smaller margins, so looks more appealing. -- New examples in vignettes "netdiffuseR showcase: Medical - Innovations", and "Simulating diffusion networks: Using the rdiffnet - function". +- New examples in vignettes “netdiffuseR showcase: Medical + Innovations”, and “Simulating diffusion networks: Using the rdiffnet + function”. @@ -156,7 +171,7 @@ Bugs Fixes instead of the attributes. Fixed. - transformGraphBy was returning with error when the time periods - ranged other than 1, 2, ... + ranged other than 1, 2, … New Features @@ -185,7 +200,7 @@ New features and changes only supported diffnet objects. - The function rewire_graph gains a new argument for the algorithm - "swap". Now to ensure aperiodicity in MCMC a chance of skiping a + “swap”. Now to ensure aperiodicity in MCMC a chance of skiping a rewire has been included. - The function n_rewires now has a default of 20 (before it was 100). @@ -195,8 +210,8 @@ New features and changes behaves as before following Bollobas, but now can deviate to generate graphs with no autolinks. -- In rgraph_ba, the argument eta allows implementing De Almeida et al. - (2013) Scale-free homophilic networks. +- In rgraph_ba, the argument eta allows implementing De Almeida et + al. (2013) Scale-free homophilic networks. - The functions exposure and dgr are now pure R code (C++ functions were replace since there were no significant speed gains). @@ -242,12 +257,12 @@ New functions - permute_graph permutes the values of an adjacency matrix (Conditional Uniform Graph). -- rewire_qap generates isomorphic graphs by "changing the labels". +- rewire_qap generates isomorphic graphs by “changing the labels”. Bug fixes -- ^.diffnet method was rasing to +1 power, e.g. diffnet^2 was actually +- ^.diffnet method was rasing to +1 power, e.g. diffnet^2 was actually diffnet^3. - /.diffnet was not working. @@ -268,7 +283,7 @@ Bug fixes - The function select_egoalter returned error when graph was an array. - The method [[<-.diffnet failed when replacing a dynamic attribute - with a NULL value (e.g. dn[["my_dyn_att"]] <- NULL). + with a NULL value (e.g. dn[["my_dyn_att"]] <- NULL). @@ -300,7 +315,7 @@ New features and changes non-adopters or excluded variables. - egonets_attrs now has new argument: self.attrs allows including - ego's attributes as part of the outcome so it can be used by the + ego’s attributes as part of the outcome so it can be used by the user. - plot_diffnet now uses igraph::plot.igraph for plotting instead @@ -372,7 +387,7 @@ New features and changes - In edgelist_to_adjmat use.incomplete has been replaced by keep.isolated which makes more sense for naming. Incomplete cases on times or weights are still ignored (as these cannot be processed by - the c++ 'engine'). (Reported by Tom) + the c++ ‘engine’). (Reported by Tom) - In edgelist_to_adjmat times has been replaced by t0 and t1. So now the user can import graphs with spells. @@ -397,7 +412,7 @@ New features and changes - New features for the exposure function. When graph is of class diffnet, the function accepts attrs equal to the name of some the - graph's attributes. Also, alt.graph can be specified as se, which + graph’s attributes. Also, alt.graph can be specified as se, which will be replaced by the inverse of the structural equivalence. When valued=FALSE the function will switch it to TRUE and warn the user. @@ -410,7 +425,7 @@ New features and changes - as_diffnet now has an internal function, check_as_diffnet_attrs, to check input attributes dimensions and coerce them into proper class/structure. Valid attributes are now documented in the - function's manual. + function’s manual. - New arguments for edges_coords: dev and ran allow including device + margins aspec ratio and plotting area y/x limits for improved aspect @@ -470,7 +485,7 @@ New functions instead. - New concatenating method c.diffnet for diffnet objects. This method - allows 'adding up' diffnet objects. + allows ‘adding up’ diffnet objects. - New print method for diffnet_se, objects returned by struct_equiv. @@ -485,4 +500,3 @@ CHANGES IN NETDIFFUSER VERSION 1.16.2 (2016-02-18) - First CRAN version. - diff --git a/man/drawColorKey.Rd b/man/drawColorKey.Rd index 3e14b0b..ffba22e 100644 --- a/man/drawColorKey.Rd +++ b/man/drawColorKey.Rd @@ -7,7 +7,7 @@ drawColorKey(x, tick.marks = pretty_within(x), labels = tick.marks, main = NULL, key.pos = c(0.925, 0.975, 0.05, 0.95), pos = 2, nlevels = length(tick.marks), - color.palette = viridis::viridis(nlevels), tick.width = c(0.01, + color.palette = viridisLite::viridis(nlevels), tick.width = c(0.01, 0.0075), add.box = TRUE, na.col = NULL, na.height = 0.1, na.lab = "n/a", ...) } diff --git a/man/plot_diffnet2.Rd b/man/plot_diffnet2.Rd index 9ee4d2e..c2486d2 100644 --- a/man/plot_diffnet2.Rd +++ b/man/plot_diffnet2.Rd @@ -12,11 +12,11 @@ plot_diffnet2(graph, ...) \method{plot_diffnet2}{default}(graph, toa, pers = min(toa, na.rm = TRUE):max(toa, na.rm = TRUE), - color.ramp = grDevices::colorRamp(viridis::magma(20)), layout = NULL, - key.width = 0.1, key.args = list(), main = "Diffusion dynamics", - add.map = NULL, diffmap.args = list(kde2d.args = list(n = 100)), - diffmap.alpha = 0.5, include.white = "first", - vertex.size = "degree", + color.ramp = grDevices::colorRamp(viridisLite::magma(20)), + layout = NULL, key.width = 0.1, key.args = list(), + main = "Diffusion dynamics", add.map = NULL, + diffmap.args = list(kde2d.args = list(n = 100)), diffmap.alpha = 0.5, + include.white = "first", vertex.size = "degree", minmax.relative.size = getOption("diffnet.minmax.relative.size", c(0.01, 0.04)), no.graph = FALSE, ...) } diff --git a/man/plot_infectsuscep.Rd b/man/plot_infectsuscep.Rd index 4fa0add..5238225 100644 --- a/man/plot_infectsuscep.Rd +++ b/man/plot_infectsuscep.Rd @@ -10,9 +10,9 @@ plot_infectsuscep(graph, toa, t0 = NULL, normalize = TRUE, K = 1L, main = "Distribution of Infectiousness and\\nSusceptibility", xlab = "Infectiousness of ego", ylab = "Susceptibility of ego", sub = ifelse(logscale, "(in log-scale)", NA), - color.palette = viridis::viridis_pal(), include.grid = TRUE, - exclude.zeros = FALSE, valued = getOption("diffnet.valued", FALSE), - ...) + color.palette = function(n) viridisLite::viridis(n), + include.grid = TRUE, exclude.zeros = FALSE, + valued = getOption("diffnet.valued", FALSE), ...) } \arguments{ \item{graph}{A dynamic graph (see \code{\link{netdiffuseR-graphs}}).} diff --git a/playground/curved.R b/playground/curved.R index 8f3a0d0..52099f5 100644 --- a/playground/curved.R +++ b/playground/curved.R @@ -232,7 +232,7 @@ nplot <- function( # Computing colors if (!length(vertex.color)) { vertex.color <- length(table(igraph::degree(x))) - vertex.color <- viridis::viridis(vertex.color) + vertex.color <- viridisLite::viridis(vertex.color) vertex.color <- vertex.color[ as.factor(igraph::degree(x)) ] diff --git a/src/Makevars b/src/Makevars index 2907b67..afa6b72 100644 --- a/src/Makevars +++ b/src/Makevars @@ -3,7 +3,7 @@ PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -fopenmp CXX_STD = CXX11 # This is necesary since ARMADILLO now supports OpenMP -PKG_CXXFLAGS=-fopenmp -DARMA_64BIT_WORD +PKG_CXXFLAGS=-fopenmp -DARMA_64BIT_WORD -DSTRICT_R_HEADERS # For testing #PKG_CXXFLAGS=-Wall diff --git a/src/Makevars.in b/src/Makevars.in index 43476d3..a6cccdc 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -3,7 +3,7 @@ PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) @OPENMP_CXXFLAGS@ CXX_STD = CXX11 # This is necesary since ARMADILLO now supports OpenMP -PKG_CXXFLAGS=@OPENMP_CXXFLAGS@ -DARMA_64BIT_WORD +PKG_CXXFLAGS=@OPENMP_CXXFLAGS@ -DARMA_64BIT_WORD -DSTRICT_R_HEADERS # For testing #PKG_CXXFLAGS=-Wall diff --git a/src/Makevars.win b/src/Makevars.win index f0d952a..326c75a 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -3,7 +3,7 @@ PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS) CXX_STD = CXX11 # This is necesary since ARMADILLO now supports OpenMP -PKG_CXXFLAGS=$(SHLIB_OPENMP_CXXFLAGS) -DARMA_64BIT_WORD +PKG_CXXFLAGS=$(SHLIB_OPENMP_CXXFLAGS) -DARMA_64BIT_WORD -DSTRICT_R_HEADERS # For testing #PKG_CXXFLAGS=-Wall diff --git a/src/plot.cpp b/src/plot.cpp index 1f4de0a..35cb7f0 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -334,7 +334,7 @@ List edges_arrow( const double & y1, const double & height, const double & width, - const double beta = 1.5707963267949, // PI/2 + const double beta = 1.5707963267949, // M_PI/2 NumericVector dev = NumericVector::create(), NumericVector ran = NumericVector::create(), bool curved = false @@ -400,8 +400,8 @@ List edges_arrow( double d = pow( pow(x0 - coords.at(2, 0), 2.0) + pow(y0 - coords.at(2, 1), 2.0), .5)/4.0; - coords_edge.at(1, 0) = (coords_edge.at(0, 0) + coords_edge.at(2, 0))/2.0 + cos(alpha+PI/2.0)*d; - coords_edge.at(1, 1) = (coords_edge.at(0, 1) + coords_edge.at(2, 1))/2.0 + sin(alpha+PI/2.0)*d*yexpand; + coords_edge.at(1, 0) = (coords_edge.at(0, 0) + coords_edge.at(2, 0))/2.0 + cos(alpha+M_PI/2.0)*d; + coords_edge.at(1, 1) = (coords_edge.at(0, 1) + coords_edge.at(2, 1))/2.0 + sin(alpha+M_PI/2.0)*d*yexpand; } else { coords_edge.at(1,0) = coords.at(2,0); @@ -478,16 +478,16 @@ List vertices_coords( for (unsigned i=0;i