tapply is a function in the R programming language for apply a function to subsets of a vector.
Aaa <- data.frame(amount=c(1,2,1,2,1,1,2,2,1,1,1,2,2,2,1), card=c("a","b","c","a","c","b","a","c","b","a","b","…