mountainmath / dotdensity Goto Github PK
View Code? Open in Web Editor NEWR package with convenience methods for multi-category dot density maps
License: Other
R package with convenience methods for multi-category dot density maps
License: Other
This function throws an error:
Error: 'replace' is not an exported object from 'namespace:dplyr'
This is likely due to the use of dplyr::replace
in the function's code below. dplyr
does not export a replace
method, and I think you're just using the base version of replace
here.
dot_density.proportional_re_aggregate <- function(data,parent_data,geo_match,categories,base="Population"){
#set NA to zero
d1=data %>% dplyr::replace(is.na(.), 0)
d2=parent_data %>% dplyr::replace(is.na(.), 0)
vectors=categories
# create zero vectors if we don't have them on base (for example DB geo)
for (v in setdiff(vectors,names(d1))) {
d1 <- d1 %>% dplyr::mutate(!!v := 0)
}
## compute the weights
basex=as.name(paste(base,'x',sep="."))
basey=as.name(paste(base,'y',sep="."))
## maybe should be left join, but then have to worry about what happens if there is no match. For hierarchial data should always have higher level geo!
d1 <- inner_join(d1,dplyr::select(d2 %>% as.data.frame,c(vectors,c(as.character(geo_match),base))), by=geo_match) %>%
dplyr::mutate(weight = !!quo(UQ(basex) / UQ(basey))) %>%
dplyr::replace(is.na(.), 0)
## aggregate variables up and down
## lower level geography counts might have been suppressed, reaggregating these makes sure that the total number of
## dots on the map are given by more accurate higher level geo counts, difference is distributed proportionally by *base*
for (v in vectors) {
vss=paste(v,'s',sep=".")
vs=as.name(vss)
vx=as.name(paste(v,'x',sep="."))
vy=as.name(paste(v,'y',sep="."))
d1 <- d1 %>% group_by(!!as.name(names(geo_match))) %>%
dplyr::mutate(!!vss := sum(!!vx)) %>%
ungroup() %>%
dplyr::mutate(!!v := !!quo(UQ(vx) + weight * (UQ(vy) - UQ(vs))))
}
Hi Jens,
the package looks very interesting. when trying to install, however, this error pops-out:
devtools::install_github("mountainMath/dotdensity")
Downloading GitHub repo mountainMath/dotdensity@master
from URL https://api.github.com/repos/mountainMath/dotdensity/zipball/master
Installation failed: cannot open file 'C:/Users/lorem/AppData/Local/Temp/Rtmp2z3iQo/devtools37c062352936/mountainMath-dotdensity-74e400c/vignettes/Why dotdenisty?.Rmd': Invalid argument`
My sessioninfo
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] ggridges_0.5.0 tmap_1.11-2
[3] spatialEco_1.1-0 classInt_0.2-3
[5] spData_0.2.8.3 cartogram_0.0.2
[7] viridis_0.5.1 viridisLite_0.3.0
[9] pastecs_1.3.21 rgdal_1.2-20
[11] sp_1.2-7 bindrcpp_0.2.2
[13] ggthemes_3.5.0 RColorBrewer_1.1-2
[15] sf_0.6-2 forcats_0.3.0
[17] stringr_1.3.0 dplyr_0.7.4
[19] purrr_0.2.4 readr_1.1.1
[21] tidyr_0.8.0 tibble_1.4.2
[23] ggplot2_2.2.1.9000 tidyverse_1.2.1
Same happens with R 3.4.4.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.