I have below R code which will iterate each text file which then fetches the respective parameter from each file and append it to the data frame.
Once the lapply get's over. I need a consolidated data frame in Final
How do I achieve this
files <- list.files(path="D:/Test/R/PBC", pattern="*.txt", full.names=TRUE, recursive=FALSE)
lapply(files, function(x) {
        text <- x       
        
        policy_nr <- str_extract(text,"(?<=Contract Number \\: )\\d+")
        
        if( is.na(policy_nr) == TRUE )
        {
          policy_nr <- str_extract(text,"(?<=Policy Number \\: )\\d+")
        }
        advisor_code <- str_extract(text,"(?<=Advisor Code \\: )\\d+")
        if( is.na(advisor_code) == TRUE )
        {
          advisor_code <- str_extract(text,"(?<=Advisor Code: )\\d+")
        }       
        data <- data.frame(PolicyNumber=policy_nr,AdvisorCode=advisor_code)
        
        
}
)
Final <- ?
 
    