I have a dataset looking like the following. For this datset I have a function, which creates a value for a column. My question is how to apply this function for the coulmns 2 to 2536 and afterward take the mean of all results.
ids V1 V2 V3 V4 ......
12  1  1  2  NA
13  2  1  3  1
18  NA 2  3  3
19  1  1  NA 1
AI <- function(AI) {
  ((sort(table(AI),decreasing=TRUE)[1])-0.5*
     (sum(!is.na(AI))
      - (sort(table(AI),decreasing=TRUE)[1]))) /sum(!is.na(AI))
}
 
     
    