unable to understand code

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. Without it, I can only comment on charlatan, which is a package to generate fake data in various forms, for example, telephone numbers. ch_name is a function within that package that returns the number of names in its argument

library(charlatan)
ch_name(5)
#> [1] "Miss Suellen Pfannerstill DDS" "Assunta Dickens"              
#> [3] "Miah Graham"                   "Azaria Fadel-Johns"           
#> [5] "Issac Volkman"

Created on 2020-03-18 by the reprex package (v0.3.0)