6

我很想知道R是否有一个包或方法可以从名字中猜测性别。

我正在考虑在美国国会上运行它作为测试。

我需要它来处理几种欧洲语言。

CRAN 没有这样的包。

CRAN 有性别包,但它只适用于英文名称。

genderizeR包解决的问题。请参阅我的自我回答中的链接。

4

5 回答 5

6

There is now a package on CRAN for specifically for this: gender

From the description:

Encodes gender based on names and dates of birth, using either the Social Security Administration's data set of first names by year of birth or the Census Bureau data from 1789 to 1940, both from the United States of America. By using these data sets instead of lists of male and female names, this package is able to more accurately guess the gender of a name, and it is able to report the probability that a name was male or female.

It also has a very helpful vignette demonstrating typical uses.

于 2015-02-19T08:08:56.700 回答
4

请不要接受这个作为答案,因为它是基于其他人的答案和链接。我已将此功能添加到qdap 包中,因为它适合该包。

library(qdap)

name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
    tyler, jamie, JAMES, tyrone, cheryl, drew))

name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
    tyler, jamie, JAMES, tyrone, cheryl, drew), FALSE)

name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
    tyler, jamie, JAMES, tyrone, cheryl, drew), FALSE, TRUE)

name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
    tyler, jamie, JAMES, tyrone, cheryl, drew), TRUE, FALSE)


## > name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
## +     tyler, jamie, JAMES, tyrone, cheryl, drew))
##  [1] F F F M M F M F M M F M
## Levels: F M

## > name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
## +     tyler, jamie, JAMES, tyrone, cheryl, drew), FALSE)
##  [1] B    <NA> F    B    B    F    B    B    B    M    F    B   
## Levels: B F M

## > name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
## +     tyler, jamie, JAMES, tyrone, cheryl, drew), FALSE, TRUE)
##  [1] B F F B B F B B B M F B
## Levels: B F M

## > name2sex(qcv(mary, jenn, linda, JAME, GABRIEL, OLIVA, 
## +     tyler, jamie, JAMES, tyrone, cheryl, drew), TRUE, FALSE)
##  [1] F    <NA> F    M    M    F    M    F    M    M    F    M   
## Levels: F M

编辑- 我添加了一个fuzzy.match参数来尝试基于模糊匹配猜测不可识别名称的性别,尽管这在计算上很昂贵。

于 2013-05-29T05:14:16.473 回答
4

我相信答案是“不”,但您仍然可以使用 R 来分析这一点。显然,这将是一种概率类型的答案,因为有些名称是模棱两可或唯一的。这个 stackoverflow 问题有一些有用的建议,但链接已过时。美国人口普查数据是一个很好的起点。从 2000 年美国人口普查中,您可以在http://www.census.gov/genealogy/www/data/1990surnames/names_files.html找到姓名目录和元数据。http://www.census.gov/srd/papers/pdf/rr97-2.pdfhttp://www.census.gov/population/www/documentation/twps07/twps07.pdf讨论了一些有趣的问题。

于 2013-05-29T00:03:28.230 回答
3

这个关于芬兰名字的讨论之后,我发现了一个很棒的genderizeR包,它查看一个在线数据库来确定几种语言名字的性别。

解决了!

于 2015-02-19T08:25:03.500 回答
2

根据您的实现思路,plyr包教程有一个很好的数据集

婴儿名字 1880 年至 2008 年美国前 1000 个男性和女性婴儿名字。258,000 条记录 (1000 * 2 * 129) 但只有四个变量:年份、姓名、性别和百分比。

于 2013-05-29T13:32:22.017 回答