Calculate relative frequency of list terms and its sum in R?
问题 I have data saved in a long list. This is an example of the first six lines / records: A <- list(c("JAMES","CHARLES","JAMES","RICHARD"), c("JOHN","ROBERT","CHARLES"), c("CHARLES","WILLIAM","CHARLES","MICHAEL","WILLIAM","DAVID","CHARLES","WILLIAM"), c("CHARLES"), c("CHARLES","CHARLES"), c("MATTHEW","CHARLES","JACK")) Now I would like to calculate the relative frequency with which each unique term occurs in each line / record. Based on my example I would like to achieve an output similar to