#as an example table:
FBI_Data <- data.frame(ViolentCrime=c(200,100,150,175,222), Murder=c(2,3,8,5,1), row.names=c("Conneticut", "Maine", "Vermont", "NewYork", "Indiana"))
#extracting the mean of a certain column, in this case Murder (as you already did in your example)
a <- mean(FBI_Data$Murder)
#making a filtered table, containing only those rows with a Murder value above the variable a. The second way is better for your function as it allows you to replace "Murder" with your variable
filteredRows <- subset(FBI_Data, Murder > a)
#OR
filteredRows <- FBI_Data[FBI_Data[ , "Murder"] > a , ]
#giving out the rownames of this filtered table
rownames(filteredRows)
#============================================
#your specific function might look like this:
f_high_crime_rate_states <- function(crimeName){
a <- mean(FBI_Data[,crimeName])
filteredRows <- FBI_Data[FBI_Data[ , crimeName] > a , ]
rownames(filteredRows)
}
f_high_crime_rate_states("Murder")