So within a text file in R, I need to scan through many documents looking for a paragraph with "discount rate" mentioned in it. I then want to extract the whole paragraph it is found in and only that. before and after every paragraph there is a blank line written as "" in the text file. I provided some sample code of what I have tried that is not working and a few paragraphs of a txt file, one of which includes the keywords "discount rate"
t <- c(grep(" discount rate ",txt,ignore.case = T),grep(" discounted cash flow",txt,ignore.case = T))
temp <- unlist(str_extract_all(txt,"\r\r. discount rate .\r\r"))
So my method was to try and extract all lines between "" and "" permitting that they contain "discount rate" but was clearly unsuccessful with this code.
""
" (9) any sale or disposition of any property or equipment that"
" has become damaged, worn out, obsolete or otherwise not useful or no"
" longer used by Armor Holdings in connection with the business of Armor"
" Holdings or its Restricted Subsidiaries."
""
" \"Attributable Debt\" in respect of a sale and leaseback transaction"
"means, at the time of determination, the present value of the obligation of the"
"lessee for net rental payments during the remaining term of the lease included"
"in such sale and leaseback transaction, including any period for which such"
"lease has been extended or may, at the option of the lessor, be extended. Such"
"present value shall be calculated using a discount rate equal to the rate of"
"interest implicit in such transaction, determined in accordance with GAAP."
""
" \"Beneficial Owner\" has the meaning assigned to such term in Rule 13d-3"
"and Rule 13d-5 under the Exchange Act, except that in calculating the beneficial"
"ownership of any particular \"person\" (as that term is used in Section 13(d)(3)"
"of the Exchange Act), such \"person\" shall be deemed to have beneficial ownership"
"of all securities that such \"person\" has the right to acquire by conversion or"
"exercise of other securities, whether such right is currently exercisable or is"
"exercisable only upon the occurrence of a subsequent condition. The terms"
"\"Beneficially Owns\" and \"Beneficially Owned\" shall have a corresponding meaning."
""
" \"Board of Directors\" means:"
""
" (1) with respect to a corporation, the board of directors of"
" the corporation;"
""
" (2) with respect to a partnership, the board of directors of"
" the general partner of the partnership; and"
""
" (3) with respect to any other Person, the board or committee"
" of such Person serving a similar function."
""