write a loop that extracts the number from a filename and applies it to a new list in r
# Sample filenamesfilenames <- c("file1.txt", "file22.txt", "file333.txt")
# Initialize an empty list to store extracted numbersnumbers_list <- list()
# Loop through each filename, extract the number, and add to the numbers_listfor (filename in filenames) {
number <- as.numeric(gsub("\\D", "", filename)) # Extract number numbers_list <- c(numbers_list, number) # Add number to the list}
numbers_list