worldbank / wbgviz Goto Github PK
View Code? Open in Web Editor NEWSeveral R packages for World Bank-standard visualisations, building on ggplot2
License: MIT License
Several R packages for World Bank-standard visualisations, building on ggplot2
License: MIT License
interleave_etc is not great right now
Something goes wrong when wbgdata is installed on Linux distributions:
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘wbgdata’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Warning in get_wbcache() :
Countries/series cache is stale - use refresh_wbcache() to update.
Error: package or namespace load failed for ‘wbgdata’:
.onLoad failed in loadNamespace() for 'wbgdata', details:
call: NULL
error: Can't subset columns that don't exist.
✖ Column `regionID` doesn't exist.
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/wbgdata’
With R 4.2.2 on 28 February 2023, I see:
Error: package or namespace load failed for 'wbgdata':
.onLoad failed in loadNamespace() for 'wbgdata', details:
call: select(., iso3c, region_iso3c = regionID)
error: Can't subset columns that don't exist.
✖ Column `regionID` doesn't exist.
Error: loading failed
+++ more elegant
From here: https://github.com/worldbank/sdgatlas2018/issues/4
Country Code Country Name spelling/ notes
CIV Cote d'Ivoire Côte d’Ivoire
FRO Faroe Islands Faeroe Islands
STP Sao Tome and Principe São Tomé and Príncipe
Currently this works per figure
# Hack to align legend figure-left - TODO: move this into figure() or elsewhere
g <- ggplotGrob(p)
g$layout$l[g$layout$name == "guide-box"] <- g$layout$l[g$layout$name == "guide-box"] - 1
g$theme <- style$theme()
g
It used to.
If style is set in plot= function, we can't also have it in the parent if figure object... refactor somehow.
When I try to install with devtools::install_github("worldbank/wbgviz", subdir = "wbggeo")
, I see this, which stops it installing or loading:
Error: package or namespace load failed for 'wbggeo':
.onLoad failed in loadNamespace() for 'wbggeo', details:
call: iso.alpha(unique(world$region), 3)
error: could not find function "iso.alpha"
geom_percent_col(y= value, fill= variable) throws an error like:
Error: Aesthetics must be either length 1 or the same as the data (104): fill
which makes everyone sad.
CMYK colors work at the moment by specifying the color as cmyk(...) which transforms internally to an rgb color (all R can understand). Then the pdf(colormodel="cmyk") device transforms these rgbs back to cmyk.
This process is a bit lossy as cmyk colors are overspecified (ie. two different cmyk colors can map to the same rgb), but that's not usually a big deal and the resulting PDF looks fine, at least on screen.
A bigger problem is that the rgb colors representing cmyk colors look totally different as rgb colors, for instance if outputting a png. For that reason we have to switch between style_atlas and style_atlas_cmyk as appropriate.
A slightly bigger problem, again, is that the relative luminance and related functions do not work properly for these pseudo-rgb colors, so contrasting text colors are poorly chosen (e.g. white when it should be black, etc). I added the biases
parameter to contrasting_colors() to hack around this, but it doesn't really work.
A proper solution would be to have a colormodel parameter in contrast_colors() and co, and calculate it differently (however that is) for pseudo-cmyk colors.
This needs some proper thought though.
Some country names in wbgref$all_geo$labels are different than the ones in wbgref$countries$labels, is there are reason why they are different? If not, it would be great to have the updated names in all_geo, especially since it contains economies as well.
Lines 59 to 63 in 56699d2
See wbgcharts_demo_atlas_1a_panel()
Probably recreating them is less fragile than trying to pull them out of ggplot, which might change internals..
To avoid this boilerplate:
child <- wbgdata(
country = wbgref$regions$iso3c, indicator = child_indicators,
startdate = min(years), enddate = max(years), indicator.wide = TRUE
)
child <- child %>%
filter(date %in% years) %>%
This is a hack anyway - sort out a better way of refreshing wbstats::cache()
Currently need to do:
font_import(system.file("fonts", package = "wbgcharts"))
This may be a complex one to troubleshoot.
As a consequence titles, subtitles, etc are affected. This a bug inherited from RGraphics:
RGraphics::splitString("word")
# [1] "word NA word"
The solution is to find / write an entirely new version of this function. Also a good idea since its very slow now.
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.