##install.packages("readr")
library(readr)
final_hateXplain <- read_csv("final_hateXplain.csv")
## Rows: 20109 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (7): comment, label, Race, Religion, Gender, Sexual Orientation, Miscell...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
library(dplyr)
## 
## Adjuntando el paquete: 'dplyr'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Saber cuantas Filas hay en el archivo

nrow(final_hateXplain)
## [1] 20109

Saber cuantas columnas tiene el archivo

ncol(final_hateXplain)
## [1] 7

Saber que tipo de variable son

spec(final_hateXplain)
## cols(
##   comment = col_character(),
##   label = col_character(),
##   Race = col_character(),
##   Religion = col_character(),
##   Gender = col_character(),
##   `Sexual Orientation` = col_character(),
##   Miscellaneous = col_character()
## )

Mirar los priemros registros del archivo

head(final_hateXplain,15)
## # A tibble: 15 × 7
##    comment        label Race  Religion Gender `Sexual Orientation` Miscellaneous
##    <chr>          <chr> <chr> <chr>    <chr>  <chr>                <chr>        
##  1 "0 u0 lmao wo… norm… No_r… Nonreli… No_ge… No_orientation       None         
##  2 "1 0 th floor… offe… No_r… Nonreli… No_ge… No_orientation       Other        
##  3 "1 0 yrs <num… hate… Afri… Nonreli… No_ge… No_orientation       None         
##  4 "1 2 h ago ch… offe… Asian Nonreli… No_ge… No_orientation       None         
##  5 "1 8 th centu… norm… No_r… Nonreli… No_ge… No_orientation       None         
##  6 "1 9 3 0 sger… hate… Cauc… Jewish   No_ge… No_orientation       None         
##  7 "1 9 5 0 whit… hate… Afri… Nonreli… No_ge… No_orientation       None         
##  8 "1 h de retar… norm… No_r… Nonreli… No_ge… No_orientation       None         
##  9 "1 st wave fe… norm… No_r… Nonreli… Women  No_orientation       None         
## 10 "2 3 andme is… hate… No_r… Jewish   No_ge… No_orientation       None         
## 11 "2 k do not p… norm… Afri… Nonreli… No_ge… No_orientation       None         
## 12 "2 v2 challs … norm… No_r… Nonreli… No_ge… No_orientation       None         
## 13 "2 x 3 xy <nu… norm… No_r… Nonreli… No_ge… No_orientation       None         
## 14 "3 novices cm… norm… No_r… Nonreli… No_ge… No_orientation       None         
## 15 "4 chan humou… hate… Afri… Nonreli… No_ge… No_orientation       None

##Cadena de Operaciones

final_hateXplain%>%head(15)
## # A tibble: 15 × 7
##    comment        label Race  Religion Gender `Sexual Orientation` Miscellaneous
##    <chr>          <chr> <chr> <chr>    <chr>  <chr>                <chr>        
##  1 "0 u0 lmao wo… norm… No_r… Nonreli… No_ge… No_orientation       None         
##  2 "1 0 th floor… offe… No_r… Nonreli… No_ge… No_orientation       Other        
##  3 "1 0 yrs <num… hate… Afri… Nonreli… No_ge… No_orientation       None         
##  4 "1 2 h ago ch… offe… Asian Nonreli… No_ge… No_orientation       None         
##  5 "1 8 th centu… norm… No_r… Nonreli… No_ge… No_orientation       None         
##  6 "1 9 3 0 sger… hate… Cauc… Jewish   No_ge… No_orientation       None         
##  7 "1 9 5 0 whit… hate… Afri… Nonreli… No_ge… No_orientation       None         
##  8 "1 h de retar… norm… No_r… Nonreli… No_ge… No_orientation       None         
##  9 "1 st wave fe… norm… No_r… Nonreli… Women  No_orientation       None         
## 10 "2 3 andme is… hate… No_r… Jewish   No_ge… No_orientation       None         
## 11 "2 k do not p… norm… Afri… Nonreli… No_ge… No_orientation       None         
## 12 "2 v2 challs … norm… No_r… Nonreli… No_ge… No_orientation       None         
## 13 "2 x 3 xy <nu… norm… No_r… Nonreli… No_ge… No_orientation       None         
## 14 "3 novices cm… norm… No_r… Nonreli… No_ge… No_orientation       None         
## 15 "4 chan humou… hate… Afri… Nonreli… No_ge… No_orientation       None

Vamos a analizar los datos de raza, religion, orientacion sexual y etiqueta

final_hateXplain %>%
  select(label, Race, Religion, `Sexual Orientation`)
## # A tibble: 20,109 × 4
##    label      Race      Religion     `Sexual Orientation`
##    <chr>      <chr>     <chr>        <chr>               
##  1 normal     No_race   Nonreligious No_orientation      
##  2 offensive  No_race   Nonreligious No_orientation      
##  3 hatespeech African   Nonreligious No_orientation      
##  4 offensive  Asian     Nonreligious No_orientation      
##  5 normal     No_race   Nonreligious No_orientation      
##  6 hatespeech Caucasian Jewish       No_orientation      
##  7 hatespeech African   Nonreligious No_orientation      
##  8 normal     No_race   Nonreligious No_orientation      
##  9 normal     No_race   Nonreligious No_orientation      
## 10 hatespeech No_race   Jewish       No_orientation      
## # ℹ 20,099 more rows

Se puede ver que los datos proporcionados indican que los comentarios de ciberacoso no se encuentran muy tipificados segun su categoria debido a que mayoria de los datos se encuentran No_race, Nonreligious,No_orientation.

final_hateXplain %>%
  select(comment:Religion,Race,`Sexual Orientation`)  %>%
  count(Religion, Race, `Sexual Orientation`) %>%
  arrange(desc(n))
## # A tibble: 91 × 4
##    Religion     Race      `Sexual Orientation`     n
##    <chr>        <chr>     <chr>                <int>
##  1 Nonreligious No_race   No_orientation        9099
##  2 Nonreligious African   No_orientation        2873
##  3 Nonreligious No_race   Homosexual            1433
##  4 Islam        No_race   No_orientation        1414
##  5 Jewish       No_race   No_orientation        1251
##  6 Islam        Arab      No_orientation         683
##  7 Nonreligious Caucasian No_orientation         618
##  8 Nonreligious Arab      No_orientation         336
##  9 Nonreligious Asian     No_orientation         330
## 10 Jewish       African   No_orientation         293
## # ℹ 81 more rows

Con el codigo anterior nos damos cuenta que son 9099 comentarios que no estan tipificados en la categoria de Religion, raza y orientacion sexual.

final_hateXplain %>%
  select(comment:Religion,Race,)  %>%
  count(Religion) %>%
  arrange(desc(n))
## # A tibble: 6 × 2
##   Religion         n
##   <chr>        <int>
## 1 Nonreligious 15387
## 2 Islam         2559
## 3 Jewish        1950
## 4 Christian      163
## 5 Hindu           42
## 6 Buddhism         8

La mayor cantidad de los comentarios son de la religion islam con 2559 y la menor religion en los comentarios es el budismo.

final_hateXplain %>%
  select(comment:Race, `Sexual Orientation`)  %>%
  count(`Sexual Orientation`) %>%
  arrange(desc(n))
## # A tibble: 5 × 2
##   `Sexual Orientation`     n
##   <chr>                <int>
## 1 No_orientation       17827
## 2 Homosexual            2163
## 3 Heterosexual           113
## 4 Asexual                  4
## 5 Bisexual                 2

Y la orientacion sexual mas comun en la tipificacion de los comentarios es la homosexual con una cantidad de 2163