Now you can easily find out using this new shiny app! In this post I use the R function frequency table compiled by John Myles White in 2009 in which he counts the occurrences of words in the source files of all CRAN packages.
I take his table and I modify it slightly to include a ranking system as well as a count of the number of characters in each function. In this Shiny application you can see both frequencies of functions graphically for a user specified range as well as find within the frequency chart easily search by imputing function names.
Play with the shiny app!
I before creating the shiny App I needed to work on the frequency data a bit:
First off get the CSV file provided by John Myles White:
freqTable <- read.csv("r_function_frequencies.csv") freqTable<-freqTable[!is.na(freqTable[,1]),] # Let's look at the data head(freqTable) freqTable <-freqTable[order(freqTable$Call.Count, decreasing = T),] # Okay so we have over 27,000 words with some of them appearing as
# infrequently as 12 times. Let's make the minimum 25 occurrences. # freqTable <- freqTable[freqTable$Call.Count>=25,] # Convert the freqTable data from factors to letters freqTable[,1] <- as.character(freqTable[,1]) # When we rank the functions by occurance we have a total of 660
# different levels numbers <- sort(unique(freqTable[,2]), decreasing=T) nrank <- 1:length(numbers) # This will create a ranking from 1 to length of unique frequencies for (i in numbers) freqTable$rank[freqTable[,2]==i] <- nrank[i==numbers] # Create a number of characters vector to be added to the frequency table freqTable$nchar <- nchar(freqTable[,1]) # Save the table for access in Shiny save(freqTable, file="freqTable.Rdata")
Post a Comment