See attached document for full assignment.The book,Because of See attached document for full assignment.library(stringr) # use stringr library# function checkdollar to check and return all dollar words in a filecheckdollar <- function(fileName){# open fileconn <-…