Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Nov 16, 2023
1 parent 78f84ad commit f082c46
Show file tree
Hide file tree
Showing 17 changed files with 904 additions and 0 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cran-comments.md
^docs$
^pkgdown$
^\.github$
^altdoc$
45 changes: 45 additions & 0 deletions altdoc/docsify.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- index.html -->

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/themes/vue.css" />
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: '$ALTDOC_PACKAGE_NAME',
repo: '$ALTDOC_PACKAGE_URL_GITHUB',
loadSidebar: true,
subMaxLevel: 2,
search: {
placeholder: 'Search',
depth: 3,
},
auto2top: true,
copyCode: {
buttonText : 'Copy',
errorText : 'Error',
successText: 'Copied'
},
plugins: [
function(hook) {
var footer = ["<a href='$ALTDOC_PACKAGE_URL'> <code> $ALTDOC_PACKAGE_NAME </code> v. $ALTDOC_PACKAGE_VERSION </a> | Documentation made with <a href='https://altdoc.etiennebacher.com/'> <code> altdoc </code> v. $ALTDOC_VERSION</a>"].join('');

hook.afterEach(function(html) {
return html + footer;
});
}
]
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1.24.1/components/prism-r.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions altdoc/docsify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* [Home](/)
* [Changelog]($ALTDOC_NEWS)
$ALTDOC_VIGNETTE_BLOCK
$ALTDOC_MAN_BLOCK
* [Code of Conduct]($ALTDOC_CODE_OF_CONDUCT)
* [License]($ALTDOC_LICENSE)
95 changes: 95 additions & 0 deletions docs/NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# WDI 2.7.8.9000

- Fix a bug where ISO3 codes were wrongly attributed to column `iso2c` ([#54](https://github.com/vincentarelbundock/WDI//issues/54)).

## WDI 2.7.8

- Move to `jsonlite`
- `end` is NULL by default

## WDI 2.7.7

- Update the cache

## WDI 2.7.6

- `WDI(extra = TRUE)` includes a new `lastupdated` column.

## WDI 2.7.5

- Add the observation status (whether an observation is a forecast) when `extra = TRUE` in `WDI()` ([#48](https://github.com/vincentarelbundock/WDI//issues/48))
- Updated cache

## WDI 2.7.4

- Bug fix for on-the-fly rename

## WDI 2.7.3

- Better error message
- Bug fixes

## WDI 2.7.2

- Add support for several languages with the "language" argument in `WDI()` ([#15](https://github.com/vincentarelbundock/WDI//issues/15))
- Add "latest" argument in `WDI()`, to fetch the most recent non-NA values ([#29](https://github.com/vincentarelbundock/WDI//issues/29), [#43](https://github.com/vincentarelbundock/WDI//issues/43))
- Speed improvement in WDIbulk (Thanks to [@etiennebacher](https://github.com/etiennebacher))
- WDIbulk gets a `timeout` argument

## WDI 2.7.1

- Bug: did not download all countries
- WDIcache did not retrieve regions

## WDI 2.7.0

- API v2
- Fix a breaking change after API v2
- per\_page not large enough when dataset is big
- Monthly and quarterly data

## WDI 2.6.0

- `start` and `end` are NULL as default and download all available years.
- `label` attribute to the return data.frame includes descriptive labels for each
- `WDIbulk` function to download all of WDI
- WDIcache and data trim whitespace from region names

## WDI 2.5.1

- New # WDI numbering scheme
- Updated country and indicator data

## WDI 2.5.0

- Namespace issues (thanks to Jan Dietrich)
- Updated the list of available indicators
- Allow iso3c or iso2c as input for country argument
- Rolled-back indicator input clean up because too aggressive (Thanks to Geoff Wright)
- Rename columns automatically when using a named vector

## WDI 2.4.0

- Call RJSONIO::fromJSON explicitly to avoid conflict with JSON package (Thanks to Richard Cotton)

## WDI 2.3.0

- Change default start/end date per user request

## WDI 2.2.0

- Bug: country names were stripped of digits

## WDI 2.1.0

- Fixed various issues (thanks to Matthieu Stigler for bug reports and patches)
- Faster downloads when requesting multiple countries (leveraging the US;BR;CA API syntax)

## WDI 2.0.0

- Now uses JSON instead of XML (Faster, easier)
- WDIcache function now allows users to update the locally stored database of available WDI series
- Fixed doc examples
- Documentation now uses roxygen2
- Moved development to github
- Series and country info now in a single data list. utf-8 encoding fixed
141 changes: 141 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# World Bank data in `R`

The `WDI` package allows users to search and download data from over 40 datasets hosted by the World Bank, including the World Development Indicators ('WDI'), International Debt Statistics, Doing Business, Human Capital Index, and Sub-national Poverty indicators.

<!-- badges: start -->

![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/WDI)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/vincentarelbundock/WDI?branch=master&svg=true)](https://ci.appveyor.com/project/vincentarelbundock/WDI)
[![R build status](https://github.com/vincentarelbundock/WDI/workflows/R-CMD-check/badge.svg)](https://github.com/vincentarelbundock/WDI/actions)

<!-- badges: end -->

## Installation

`WDI` is published on CRAN and so can be installed by simply typing this in the `R` console:

```r
install.packages('WDI')
```

To install the development version of the package, use `remotes`:

```r
library(remotes)
install_github('vincentarelbundock/WDI')
```

## Searching for data

You can search for data by using keywords in `WDIsearch`. For instance, if you are looking for data on Gross Domestic Product:

```r
WDIsearch('gdp')
```

Which produces this:

```r
> WDIsearch('gdp')[1:10,]
indicator name
[1,] "BG.GSR.NFSV.GD.ZS" "Trade in services (% of GDP)"
[2,] "BM.KLT.DINV.GD.ZS" "Foreign direct investment, net outflows (% of GDP)"
[3,] "BN.CAB.XOKA.GD.ZS" "Current account balance (% of GDP)"
[4,] "BN.CUR.GDPM.ZS" "Current account balance excluding net official capital grants (% of GDP)"
[5,] "BN.GSR.FCTY.CD.ZS" "Net income (% of GDP)"
[6,] "BN.KLT.DINV.CD.ZS" "Foreign direct investment (% of GDP)"
[7,] "BN.KLT.PRVT.GD.ZS" "Private capital flows, total (% of GDP)"
[8,] "BN.TRF.CURR.CD.ZS" "Net current transfers (% of GDP)"
[9,] "BNCABFUNDCD_" "Current Account Balance, %GDP"
[10,] "BX.KLT.DINV.WD.GD.ZS" "Foreign direct investment, net inflows (% of GDP)"
```

`WDIsearch` uses grep and ignores cases, so you can also use regular expressions. For instance, if you are looking for GDP per capita in constant dollars:

```r
WDIsearch('gdp.*capita.*constant')
indicator name
[1,] "GDPPCKD" "GDP per Capita, constant US$, millions"
[2,] "NY.GDP.PCAP.KD" "GDP per capita (constant 2000 US$)"
[3,] "NY.GDP.PCAP.KN" "GDP per capita (constant LCU)"
[4,] "NY.GDP.PCAP.PP.KD" "GDP per capita, PPP (constant 2005 international $)"
```

## Download and use the data

Download a series you like for the countries you like:

```r
dat = WDI(indicator='NY.GDP.PCAP.KD', country=c('MX','CA','US'), start=1960, end=2012)
```

Look at the data:

```r
head(dat)
iso2c country NY.GDP.PCAP.KD year
1 CA Canada 9374.883 1960
2 CA Canada 9479.824 1961
3 CA Canada 9967.366 1962
4 CA Canada 10290.362 1963
5 CA Canada 10774.653 1964
6 CA Canada 11283.606 1965
```

Plot the data:

```r
library(ggplot2)
ggplot(dat, aes(year, NY.GDP.PCAP.KD, color=country)) + geom_line() +
xlab('Year') + ylab('GDP per capita')
```

![GDP per capita in North America](https://raw.githubusercontent.com/vincentarelbundock/WDI/main/web/gdp_per_capita.jpg)

Note: You can use `country='all'` to download data for all available countries. You can also feed a vector of indicator strings if you want to download multiple indicators at once.

## Monthly or quarterly data

Some World Bank series are available at the monthly or quarterly frequency. You can download those simply using the `start` and `end` arguments:

```r
WDI(indicator = 'DPANUSSPB', country = 'CHN', start = '2012M01', end = '2012M05')

iso2c country DPANUSSPB year
1 CHN China 6.324130 2012M05
2 CHN China 6.303810 2012M04
3 CHN China 6.313545 2012M03
4 CHN China 6.300286 2012M02
5 CHN China 6.313091 2012M01
```

## Automatic rename

If the vector that you supply to `WDI` is named, the function will automatically rename columns where possible.

```r
dat <- WDI(indicator = c("gdp_per_capita" = "NY.GDP.PCAP.KD",
"population" = "SP.POP.TOTL"))
head(dat)
iso2c country year gdp_per_capita population
1 1A Arab World 2005 5378.379 316264728
2 1A Arab World 2006 5594.899 323773264
3 1A Arab World 2007 5711.663 331653797
4 1A Arab World 2008 5898.516 339825483
5 1A Arab World 2009 5782.422 348145094
6 1A Arab World 2010 5916.330 356508908
```

## Updating series list

To speed up search, `WDI` ships with a local list of all available WDI series. This list will be updated semi-regularly, but you may still want to update it manually to get access to the very latest data series. To do so, use the `cache` function:

```r
new_cache = WDIcache()
WDIsearch('gdp', cache=new_cache)
```

## Bugs, suggestions, etc.

Thanks for using `WDI`! Please send all bug reports and suggestions through the github issue tracker or by email to [vincent.arel-bundock@umontreal.ca](mailto:vincent.arel-bundock@umontreal.ca)

12 changes: 12 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
* [Home](/)
* [Changelog](NEWS.md)
* Reference
- [languages_supported](man/languages_supported)
- [WDI_data](man/WDI_data)
- [WDI-package](man/WDI-package)
- [wdi](man/wdi.dl)
- [WDI](man/WDI)
- [wdi](man/wdi.query)
- [WDIbulk](man/WDIbulk)
- [WDIcache](man/WDIcache)
- [WDIsearch](man/WDIsearch)
45 changes: 45 additions & 0 deletions docs/docsify.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- index.html -->

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/themes/vue.css" />
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: '$ALTDOC_PACKAGE_NAME',
repo: '$ALTDOC_PACKAGE_URL_GITHUB',
loadSidebar: true,
subMaxLevel: 2,
search: {
placeholder: 'Search',
depth: 3,
},
auto2top: true,
copyCode: {
buttonText : 'Copy',
errorText : 'Error',
successText: 'Copied'
},
plugins: [
function(hook) {
var footer = ["<a href='$ALTDOC_PACKAGE_URL'> <code> $ALTDOC_PACKAGE_NAME </code> v. $ALTDOC_PACKAGE_VERSION </a> | Documentation made with <a href='https://altdoc.etiennebacher.com/'> <code> altdoc </code> v. $ALTDOC_VERSION</a>"].join('');

hook.afterEach(function(html) {
return html + footer;
});
}
]
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1.24.1/components/prism-r.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
</body>
</html>
44 changes: 44 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!-- index.html -->

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/themes/vue.css" />
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'WDI',
loadSidebar: true,
subMaxLevel: 2,
search: {
placeholder: 'Search',
depth: 3,
},
auto2top: true,
copyCode: {
buttonText : 'Copy',
errorText : 'Error',
successText: 'Copied'
},
plugins: [
function(hook) {
var footer = ["<a href='https://vincentarelbundock.github.io/WDI/'> <code> WDI </code> v. 2.7.8.9000 </a> | Documentation made with <a href='https://altdoc.etiennebacher.com/'> <code> altdoc </code> v. 0.2.2.9006</a>"].join('');

hook.afterEach(function(html) {
return html + footer;
});
}
]
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1.24.1/components/prism-r.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
</body>
</html>
Loading

0 comments on commit f082c46

Please sign in to comment.