1

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

AntoniosK
  • 15,991
  • 2
  • 19
  • 32
Mohamed Rahouma
  • 1,084
  • 9
  • 20

1 Answers1

4

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))
akrun
  • 874,273
  • 37
  • 540
  • 662
  • 1
    I also tried this that edited fixed the variable itself based on your comment `data$new.Article.Subspecialty<-tolower(data$new.Article.Subspecialty); table(data$new.Article.Subspecialty)` – Mohamed Rahouma Nov 12 '19 at 18:25
  • @MohamedRahouma Thank you for the comments. Regarding your second comment, do you need any other fix – akrun Nov 12 '19 at 18:27
  • No. thanlks I am just sharing what I did and found it useful . Appreciate your follow-up – Mohamed Rahouma Nov 12 '19 at 19:23