write a loop which extracts the last character from a list of files and applies that number to a new list in r

main.r
file_list <- c("file1.txt", "file2.txt", "file3.txt")
new_list <- vector()

for (file in file_list) {
  last_char <- substr(file, nchar(file), nchar(file))
  new_list <- c(new_list, last_char)
}

new_list
205 chars
10 lines

related categories

gistlibby LogSnag