如何使用数据框制作直方图

时间:2019-06-24 14:01:42

标签: r

我试图对列表的频率进行直方图显示,列表如下:

> x[1:15,]
    X                             x
1   1   JUAN DOMINGOGONZALEZDELGADO
2   2   FRANCISCO JAVIERVELARAMIREZ
3   3        JUAN CARLOSPEREZMEDINA
4   4         ARMANDOSALINASSALINAS
5   5   JOSE FELIXZAMBRANOAMEZQUITA
6   6           GABRIELMONTIELRIVAS
7   7       DONACIANOSANCHEZHERRERA
8   8            JUAN MARTINXHUERTA
9   9 ALVARO ALEJANDROGONZALEZRAMOS
10 10     OMAR ROMANCASTAÑEDALOPEZ 
11 11              IGNACIOBUENOCANO
12 12       RAFAELBETANCOURTDELGADO
13 13  LUIS ALBERTOCASTILLOESCOBEDO
14 14       VICTORHERNANDEZGONZALEZ
15 15              FATIMAROMOTORRES

为此,我将其更改为频率表,如下所示:

> y[1:15,]
    X                                                                   x Freq
1   1                                                                       15
2   2                                             JULIO CESAR ORDAZFLORES    1
3   3                                         MARCOS ANTONIOCUEVASNAVARRO    1
4   4       DULEY DILTON                               TRIBOUILLIERLOARCA    1
5   5                                                 ANTONIORAMIREZLOPEZ    2
6   6                                        BRAYAN ALEJANDROOJEDARAMIREZ    1
7   7                                           JOSE DE JESUSESCOTOCORTEZ    1
8   8                                                   AARONFLORESGARCIA    1
9   9                                                ABIGAILNAVARROAMBRIZ    1
10 10                                              ABILENYRODRIGUEZORTEGA    1
11 11                                             ABRAHAMHERNANDEZRAMIREZ    1
12 12                                               ABRAHAMPONCEALCANTARA    1
13 13                                          ADRIAN VAZQUEZ BUSTAMANTE     2
14 14                                             ADRIANHERNANDEZBERMUDEZ   28
15 15                                           ALAN ORLANDOCASTILLALOPEZ   11

当我尝试hist(x)hist(x[,2])时,我得到:

Error in hist.default(x) : 'x' must be numeric

如果我尝试hist(y[,3]),会得到一个奇怪的直方图,这是不希望的,那么现在如何制作名称列表频率的直方图?

0 个答案:

没有答案