Skip to content

Commit

Permalink
[1.1.1]
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce committed Nov 29, 2021
1 parent 13c4d54 commit 1c3102c
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
cache: packages
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ChineseNames
Title: Chinese Name Database 1930-2008
Version: 1.1.0
Date: 2021-06-21
Version: 1.1.1
Date: 2021-11-29
Authors@R:
c(person(given = "Han-Wu-Shuang",
family = "Bao",
Expand All @@ -26,5 +26,5 @@ URL: https://github.com/psychbruce/ChineseNames
BugReports: https://github.com/psychbruce/ChineseNames/issues
Depends: R (>= 3.6.0)
Imports: bruceR, data.table
Suggests: babynames, dplyr
RoxygenNote: 7.1.1
Suggests: babynames, car, dplyr
RoxygenNote: 7.1.2
70 changes: 45 additions & 25 deletions R/ChineseNames.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
#'
#' @section Citation:
#' Bao, H.-W.-S. (2021). ChineseNames: Chinese Name Database 1930-2008.
#' R package version 1.1.0.
#' R package version 1.1.1.
#' \url{https://CRAN.R-project.org/package=ChineseNames}
#'
#' Bao, H.-W.-S., Cai, H., Jing, Y., & Wang, J. (2021).
#' Novel evidence for the increasing prevalence of unique names in China:
#' A reply to Ogihara (2020). \emph{Frontiers in Psychology, 12}, 731244.
#' \url{https://www.frontiersin.org/articles/10.3389/fpsyg.2021.731244/full}
#'
#' @docType package
#' @name ChineseNames
NULL
Expand All @@ -40,8 +45,12 @@ NULL
"\nTo use the `ChineseNames` package in publications, please cite:\n\n",
"Bao, H.-W.-S. (2021). ",
"ChineseNames: Chinese Name Database 1930-2008. ",
"R package version 1.1.0. ",
"https://CRAN.R-project.org/package=ChineseNames\n")
"R package version 1.1.1. ",
"https://CRAN.R-project.org/package=ChineseNames\n\n",
"Other references:\n\n",
"Bao, H.-W.-S., Cai, H., Jing, Y., & Wang, J. (2021). ",
"Novel evidence for the increasing prevalence of unique names in China: ",
"A reply to Ogihara (2020). Frontiers in Psychology, 12, 731244.\n")
}


Expand Down Expand Up @@ -145,17 +154,16 @@ NULL
#' [and \code{var.birthyear}, if necessary].
#' }
#'
#' \emph{Caution.} Name-character uniqueness (NU) of cases
#' with birth year >= 2010 would not be accurately computed
#' due to the year limitation of this name database.
#' \emph{Caution.} Name-character uniqueness (NU) for birth year >= 2010
#' is estimated by forecasting and thereby may not be accurate.
#'
#' @param data Data frame.
#' @param var.fullname Variable name of Chinese full names (e.g., \code{"name"}).
#' @param var.surname Variable name of Chinese surnames (e.g., \code{"surname"}).
#' @param var.givenname Variable name of Chinese given names (e.g., \code{"givenname"}).
#' @param var.birthyear Variable name of birth year (e.g., \code{"birth"}).
#' @param name \strong{If no \code{data}}, you can just input a vector of full name(s).
#' @param birth \strong{If no \code{data}}, you can just input a vector of birth year(s).
#' @param name If no \code{data}, you can just input a vector of full name(s).
#' @param birth If no \code{data}, you can just input a vector of birth year(s).
#' @param index Which indices to compute?
#'
#' By default, it computes all available name indices:
Expand Down Expand Up @@ -184,15 +192,25 @@ NULL
#' Default is \code{FALSE}.
#'
#' @return
#' A new data frame (\code{data.table}) with name indices appended.
#' Full names are split into \code{name0}
#' (surnames, with compound surnames automatically detected),
#' A new data frame (of class \code{data.table}) with name indices appended.
#' Full names are split into \code{name0} (surnames, with compound surnames automatically detected),
#' \code{name1}, \code{name2}, and \code{name3} (given-name characters).
#'
#' @note For details and examples, see \url{https://github.com/psychbruce/ChineseNames}
#' @note
#' For details and examples, see \url{https://github.com/psychbruce/ChineseNames}
#'
#' @section Citation:
#' Bao, H.-W.-S. (2021). ChineseNames: Chinese Name Database 1930-2008.
#' R package version 1.1.1.
#' \url{https://CRAN.R-project.org/package=ChineseNames}
#'
#' Bao, H.-W.-S., Cai, H., Jing, Y., & Wang, J. (2021).
#' Novel evidence for the increasing prevalence of unique names in China:
#' A reply to Ogihara (2020). \emph{Frontiers in Psychology, 12}, 731244.
#' \url{https://www.frontiersin.org/articles/10.3389/fpsyg.2021.731244/full}
#'
#' @examples
#' ## Prepare
#' ## Prepare ##
#' sn=familyname$surname[1:12]
#' gn=c(top100name.year$name.all.1960[1:6],
#' top100name.year$name.all.2000[1:6],
Expand All @@ -201,12 +219,13 @@ NULL
#' demodata=data.frame(name=paste0(sn, gn),
#' birth=c(1960:1965, 2000:2005,
#' 1960:1965, 2000:2005))
#' # View(demodata)
#'
#' ## Compute
#' ## Compute ##
#' newdata=compute_name_index(demodata,
#' var.fullname="name",
#' var.birthyear="birth")
#' # use View(newdata) to see the results
#' # View(newdata)
#'
#' @import data.table
#' @importFrom bruceR dtime Print MEAN LOOKUP
Expand Down Expand Up @@ -243,7 +262,7 @@ compute_name_index=function(data=NULL,
ref6=data.table(char=givenname$character, code=6, ppm=givenname$ppm.2000_2008)
ref.long=rbind(ref0, ref1, ref2, ref3, ref4, ref5, ref6)

## Debug ##
## Initialize ##

`.`=NULL
NLen=SNU=SNI=NU=CCU=NG=NV=NW=NC=NULL
Expand Down Expand Up @@ -383,30 +402,31 @@ compute_name_index=function(data=NULL,
}


#' @importFrom bruceR LOOKUP
compute_NU_char=function(data, ref.long, var.char, var.year=NULL, approx=TRUE) {
ppm1=ppm2=weight1=weight2=NULL
if(is.null(var.year)) {
ppm=bruceR::LOOKUP(data, var.char,
ChineseNames::givenname, "character", "name.ppm",
return="new.value")
ppm=LOOKUP(data, var.char,
ChineseNames::givenname, "character", "name.ppm",
return="new.value")
} else {
d=as.data.frame(data)[c(var.char, var.year)]
names(d)=c("char", "year")
d$code=bruceR::RECODE(
d$code=car::recode(
d$year, "lo:1929=1; 1930:1959=1; 1960:1969=2; 1970:1979=3; 1980:1989=4; 1990:1999=5; 2000:2009=6; else=0")
d$code1=bruceR::RECODE(
d$code1=car::recode(
d$year, "lo:1954=1; 1955:1964=1; 1965:1974=2; 1975:1984=3; 1985:1994=4; 1995:2004=5; 2005:2009=6; else=0")
d$code2=bruceR::RECODE(
d$code2=car::recode(
d$year, "lo:1954=1; 1955:1964=2; 1965:1974=3; 1975:1984=4; 1985:1994=5; 1995:2004=6; 2005:2009=6; else=0")
d$weight1=5-(d$year%%10)
d$weight1=ifelse(d$weight1>0, d$weight1, 10+d$weight1)
d$weight1=ifelse(is.na(d$weight1), 5, d$weight1)
d$weight2=10-d$weight1
if(approx==FALSE) {
d$ppm=bruceR::LOOKUP(d, c("char", "code"), ref.long, c("char", "code"), "ppm", return="new.value")
d$ppm=LOOKUP(d, c("char", "code"), ref.long, c("char", "code"), "ppm", return="new.value")
} else {
d$ppm1=bruceR::LOOKUP(d, c("char", "code1"), ref.long, c("char", "code"), "ppm", return="new.value")
d$ppm2=bruceR::LOOKUP(d, c("char", "code2"), ref.long, c("char", "code"), "ppm", return="new.value")
d$ppm1=LOOKUP(d, c("char", "code1"), ref.long, c("char", "code"), "ppm", return="new.value")
d$ppm2=LOOKUP(d, c("char", "code2"), ref.long, c("char", "code"), "ppm", return="new.value")
d=dplyr::mutate(d, ppm=(ppm1*weight1+ppm2*weight2)/10)
}
}
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ChineseNames <a href="https://github.com/psychbruce/ChineseNames/tree/master/logo"><img src="https://raw.githubusercontent.com/psychbruce/ChineseNames/master/logo/ChineseNames-logo-min.png" align="right" height="240px"/></a>
# ChineseNames <a href="https://github.com/psychbruce/ChineseNames/tree/master/logo"><img src="https://raw.githubusercontent.com/psychbruce/ChineseNames/master/logo/ChineseNames-logo-min.png" align="right" height="180px"/></a>

**Chinese Name Database 1930-2008**

A database of Chinese surnames and Chinese given names (1930-2008). This database contains nationwide frequency statistics of 1,806 Chinese surnames and 2,614 Chinese characters used in given names, covering about 1.2 billion Han Chinese population (96.8% of the Han Chinese household-registered population born from 1930 to 2008 and still alive in 2008). This package also contains a function for computing multiple features of Chinese surnames and Chinese given names for scientific research (e.g., name uniqueness, name gender, name valence, and name warmth/competence).

[![CRAN-Version](https://www.r-pkg.org/badges/version/ChineseNames?color=red)](https://CRAN.R-project.org/package=ChineseNames) [![CRAN-Downloads](https://cranlogs.r-pkg.org/badges/grand-total/ChineseNames)](https://CRAN.R-project.org/package=ChineseNames) [![GitHub-Version](https://img.shields.io/github/r-package/v/psychbruce/ChineseNames?label=GitHub&color=orange)](https://github.com/psychbruce/ChineseNames) [![Travis-Build-Status](https://travis-ci.com/psychbruce/ChineseNames.svg?branch=master)](https://travis-ci.com/psychbruce/ChineseNames) [![Logo-Designer](https://img.shields.io/badge/Logo%20Designer-Meijia%20Li-blueviolet?logo=github-sponsors)](https://github.com/Stellapros) [![GitHub-Stars](https://img.shields.io/github/stars/psychbruce/ChineseNames?style=social)](https://github.com/psychbruce/ChineseNames/stargazers)
[![CRAN-Version](https://www.r-pkg.org/badges/version/ChineseNames?color=red)](https://CRAN.R-project.org/package=ChineseNames) [![CRAN-Downloads](https://cranlogs.r-pkg.org/badges/grand-total/ChineseNames)](https://CRAN.R-project.org/package=ChineseNames) [![GitHub-Version](https://img.shields.io/github/r-package/v/psychbruce/ChineseNames?label=GitHub&color=orange)](https://github.com/psychbruce/ChineseNames) [![Travis-Build-Status](https://app.travis-ci.com/psychbruce/ChineseNames.svg?branch=master)](https://app.travis-ci.com/github/psychbruce/ChineseNames) [![Logo-Designer](https://img.shields.io/badge/Logo%20Designer-Meijia%20Li-blueviolet?logo=github-sponsors)](https://github.com/Stellapros) [![GitHub-Stars](https://img.shields.io/github/stars/psychbruce/ChineseNames?style=social)](https://github.com/psychbruce/ChineseNames/stargazers)

<img src="https://s1.ax1x.com/2020/07/28/aAjUJg.jpg" width="120px" height="42px"/>

Expand All @@ -20,7 +20,8 @@ Website: [psychbruce.github.io](https://psychbruce.github.io)

## Citation

- Bao, H.-W.-S. (2021). ChineseNames: Chinese Name Database 1930-2008. R package version 1.0.0. <https://CRAN.R-project.org/package=ChineseNames> or <https://github.com/psychbruce/ChineseNames>
- Bao, H.-W.-S. (2021). ChineseNames: Chinese Name Database 1930-2008. R package version 1.1.1. <https://CRAN.R-project.org/package=ChineseNames>
- Bao, H.-W.-S., Cai, H., Jing, Y., & Wang, J. (2021). Novel evidence for the increasing prevalence of unique names in China: A reply to Ogihara (2020). *Frontiers in Psychology, 12*, 731244. <https://www.frontiersin.org/articles/10.3389/fpsyg.2021.731244/full>

## Install

Expand Down
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## News

In this version (1.1.0), I have improved the function `compute_name_index()`.
In this version (1.1.1), I have fixed a bug related to an update of `bruceR` (thanks to Prof. Brian Ripley) and modified citation information.


## Test environments

* Windows 10 (local installation), R 4.1.0
* Windows 10 (local installation), R 4.1.2
* Mac OS 11.2 (user installation), R 4.0.4
* Ubuntu 16.04 (on travis-ci.com), R 4.0.2

Expand Down
9 changes: 5 additions & 4 deletions data-csv/README-CSV.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

### Description

**`ChineseNames`** (v1.0.0) is an R package published on CRAN (<https://CRAN.R-project.org/package=ChineseNames>). To use the datasets in this package, it is highly recommended to use [R software](https://www.r-project.org/), normally within its IDE [RStudio](https://www.rstudio.com/products/rstudio/download/preview/), and install this package.
**`ChineseNames`** is an R package published on CRAN (<https://CRAN.R-project.org/package=ChineseNames>). To use the datasets of this package, it is highly recommended to use [R software](https://www.r-project.org/), normally within its IDE [RStudio](https://www.rstudio.com/products/rstudio/download/preview/), and install this package.

``` {.r}
``` r
## Install from CRAN
install.packages("ChineseNames")

Expand All @@ -28,10 +28,11 @@ For detailed description, see [README.md](https://github.com/psychbruce/ChineseN

### Citation

- Bao, H.-W.-S. (2021). ChineseNames: Chinese Name Database 1930-2008. R package version 1.0.0. <https://CRAN.R-project.org/package=ChineseNames> or <https://github.com/psychbruce/ChineseNames>
- Bao, H.-W.-S. (2021). ChineseNames: Chinese Name Database 1930-2008. R package version 1.1.1. <https://CRAN.R-project.org/package=ChineseNames>
- Bao, H.-W.-S., Cai, H., Jing, Y., & Wang, J. (2021). Novel evidence for the increasing prevalence of unique names in China: A reply to Ogihara (2020). *Frontiers in Psychology, 12*, 731244. <https://www.frontiersin.org/articles/10.3389/fpsyg.2021.731244/full>

### Supplementary Information

Example usage and application based on this name database can be found in:
An example of the usage based on this name database can be found in:

- [What can we tell from the evolution of Han Chinese names? - by Isabella Chua (March 12, 2021)](https://kontinentalist.com/stories/a-cultural-history-of-han-chinese-names-for-girls-and-boys-in-china)
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ citEntry(entry = "Misc",
textVersion =
paste("Bao, H.-W.-S. (2021).",
"ChineseNames: Chinese Name Database 1930-2008.",
"R package version 1.0.0.",
"R package version 1.1.1.",
"https://CRAN.R-project.org/package=ChineseNames")
)
7 changes: 6 additions & 1 deletion man/ChineseNames.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 22 additions & 11 deletions man/compute_name_index.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c3102c

Please sign in to comment.