How to print or display Not Available if any of my search list in (Table_search) is not available in the list I input. In the input I have three lines and I have 3 keywords to search through these lines and tell me if the keyword is present in those lines or not. If present print that line else print Not available like I showed in the desired output.
My code just prints all the available lines but that doesn't help as I need to know where is the word is missing as well.
Table_search <- list("Table 14", "Source Data:","VERSION") Table_match_list <- sapply(Table_search, grep, x = tablelist, value = TRUE) Input:
Table 14.1.1.1 (Page 1 of 2) Source Data: Listing 16.2.1.1.1 Summary of Subject Status by Respiratory/Non-Ambulatory at Event Entry Desired Output:
Table 14.1.1.1 (Page 1 of 2) Source Data: Listing 16.2.1.1.1 NA https://stackoverflow.com/questions/66095335/ignore-or-display-na-in-a-row-if-the-search-word-is-not-available-in-a-list-r February 08, 2021 at 10:52AM
没有评论:
发表评论