sammo3182 / regioncode Goto Github PK
View Code? Open in Web Editor NEWSoftware for converting regional administrative codes (China) over years
License: Other
Software for converting regional administrative codes (China) over years
License: Other
In the published version, the Chinese title of Xinjiang is incorrect. "**维吾尔自治区" instead.
Building up a pkgdown website for the package.
Given a vector of codes or names, the function can guess which year they matched the most
2area
: Converting name/code to regions hua-bei, dong-bei, etc.)2pinyin
:Converting name/codes to pinyin (probably provincial level)The full name of "Ning Xia" is wrong.
宁夏回族自治州 -> 宁夏回族自治区
library(regioncode)
regioncode(
data_input = corruption$province_id,
convert_to = "name",
year_from = 2019,
year_to = 1989,
province = TRUE
)
#> Joining with `by = join_by(prov_scode)`
#> [1] NA NA NA NA NA NA NA NA NA NA
Also check for convert_to = "code"
In ./data/江西_四川_重庆_西藏.xlsx, some name/sname values contain unrecognized or incorrect characters. For example, in line 46, '1988_name' has value ' 内江市' instead of '内江市‘. Function will return NA because of unrecognized characters.
Adding indicators to identify tiers of cities
Converting prefectures and provinces to language zones according to the 1986 or later language data
Users give a vector of codes and year, the function can return names of the prefecture, codes or names of the prefectures in another given year by choice.
Users can use a vector of complete or incomplete names to and given year to return corresponding codes or codes/names of another given year.
Achieve the code-name exchange at the provincial level.
The pinyin
package did not present Shaanxi correctly.
Scraping administrative region codes from the government webpages (http://www.mca.gov.cn/article/sj/xzqh/2020/) and parse them to structural data automatically with rvest
functions.
Some towns were named as prefecturals in Yunan
The example in the vignette shows the wrong results with the new function. The input only has 18947 lines but the output has 21513 lines.
regioncode/vignettes/regioncode-vignette.Rmd
Lines 74 to 77 in f2c914e
Sometimes, cross-year conversion produces multiple outputs.
> regioncode::regioncode(df_wave1$province_q180, year_from = 1999, convert_to = "area", province = TRUE)
Error in `select()`:
! Can't subset columns that don't exist.
✖ Column `1999` doesn't exist.
Backtrace:
1. regioncode::regioncode(...)
12. dplyr:::select.data.frame(region_table, !!ls_index)
15. tidyselect::eval_select(expr(c(...)), .data)
16. tidyselect:::eval_select_impl(...)
25. tidyselect:::vars_select_eval(...)
...
28. tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
29. tidyselect:::walk_data_tree(new, data_mask, context_mask)
30. tidyselect:::as_indices_sel_impl(...)
31. tidyselect:::as_indices_impl(x, vars, call = call, strict = strict)
32. tidyselect:::chr_as_locations(x, vars, call = call)
Simplifying the method to "toCode," "toName," etc. by detecting the input's class (numeric
, characters
)
There might be a mistake in the region_table. (don't know what "<U+00A0>" stands for)
region_table[408,"2019_name"]
[1] "<U+00A0>成都市"
code2...
name2...
incompleteName
is not "none" for methods of ...2code
Preparing the package for the CRAN submission and future plans
didin‘t receive region data of Gansu, Qinghai, Shaanxi, Xinjiang, Hunan, Yunnan, Guizhou, Ningxia.
if I run the example
library(regioncode)
regioncode::regioncode(data_input = corruption$prefecture_id,
year_from = 2019,
year_to = 1999)
them R told me
Error in regioncode::regioncode(data_input = corruption$prefecture_id, :
object 'corruption' not found
library(regioncode)
names_municipality <- c("北京", # Beijing, a municipality
"海淀区", # A district of Beijing
"上海", # Shanghai, a municipality
"静安区", # A district of Shanghai
"济南市") # A prefecture of Shandong
regioncode(
data_input = names_municipality,
year_from = 2019,
year_to = 2019,
convert_to = "code",
zhixiashi = FALSE
)
#> Joining with `by = join_by(`2019_name`)`
#> [1] NA 110108 NA 310106 370100
# When `zhixiashi` is TRUE, muncipalities are
regioncode(
data_input = names_municipality,
year_from = 2019,
year_to = 2019,
convert_to = "code",
zhixiashi = TRUE
)
#> Error in `filter()`:
#> ℹ In argument: `zhixiashi`.
#> Caused by error:
#> ! `..1` must be a logical vector, not a character vector.
#> Backtrace:
#> ▆
#> 1. ├─regioncode::regioncode(...)
#> 2. │ └─region_data %>% filter(zhixiashi) at regioncode/R/regioncode.R:268:8
#> 3. ├─dplyr::filter(., zhixiashi)
#> 4. ├─dplyr:::filter.data.frame(., zhixiashi)
#> 5. │ └─dplyr:::filter_rows(.data, dots, by)
#> 6. │ └─dplyr:::filter_eval(...)
#> 7. │ ├─base::withCallingHandlers(...)
#> 8. │ └─mask$eval_all_filter(dots, env_filter)
#> 9. │ └─dplyr (local) eval()
#> 10. ├─dplyr:::dplyr_internal_error(...)
#> 11. │ └─rlang::abort(class = c(class, "dplyr:::internal_error"), dplyr_error_data = data)
#> 12. │ └─rlang:::signal_abort(cnd, .file)
#> 13. │ └─base::signalCondition(cnd)
#> 14. └─dplyr (local) `<fn>`(`<dpl:::__>`)
#> 15. └─rlang::abort(message, class = error_class, parent = parent, call = error_call)
I try to run the example code in help file,
library(regioncode)
regioncode(data_input = corruption$prefecture_id,
year_from = 2019,
year_to = 1999)
But it seem to doesn't work. The error message is
Error in regioncode(data_input = corruption$prefecture_id, year_from = 2019, :
object 'corruption' not found
I guess the toy data corruption
may not be successfully loaded.
Create a spreadsheet for administrative codes of Chinese prefectural regions from 1986 to 2019. The data frame includes two fixed columns:
~prov_name
, ~prov_code
For each year, the data ought to include the following columns:
~<year>_sname
, ~<year>_name
, ~<year>_code
See the reference from countrycode
, dotwhisker
, and interplot
Adding a Chinese version
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.