[Solved] How to extract list element names in lapply to rename files
[ad_1] We need to use names instead of name in the OP’s function, use paste0 instead of paste if we don’t need a whitespace between the names and the new string, and return ‘theNamedFile’, then apply the function directly on the ‘mylist’ ReportOp<-function(x){ theNamedFile <- paste0(names(x),”~\\Myfile.pdf”) theNamedFile } ReportOp(mylist) If we apply it using lapply … Read more