Search code examples
rfrequency

ignore case in frequency for factor variable in r


I am trying to get frequency of factors in one column using table but I realized that some factors although identical letters but different in case i.e capital letter /small letters as you can see in the attached figure. I checked the frequency of each factor using pivot table in excel (as in the screenshot below. Here is my working dataset (Link) I used the foillowing code

table ( data$new.Article.Subspecialty)

I tried the following but it gave me error. table ( data$new.Article.Subspecialty,ignore.case=T)

Error in table(data$Article.Subspecialty, ignore.case = T) : all arguments must have the same length

Anyway to solve this (may be capitalize them as in this LINK ) but this is a column in my big dataset.

Any advice will be greatly appreciated.

enter image description here


Solution

  • table doesn't have ignore.case as argument. we can convert to same case with tolower or toupper and then apply the table

    table(tolower(data$new.Article.Subspecialty))