[R] Extracting sentences with combinations of target words/terms from cancer patient text medical records

2017-07-11 Thread Paul Miller via R-help
Hello All, I need some help figuring out how to extract combinations of target words/terms from cancer patient text medical records. I've provided some sample data and code below to illustrate what I'm trying to do. At the moment, I'm trying to extract sentences that contain the word "breast" p

Re: [R] Extracting sentences with combinations of target words/terms from cancer patient text medical records

2017-07-12 Thread Paul Miller via R-help
quate? Bert On Jul 11, 2017 10:49 AM, "Paul Miller via R-help" wrote: Hello All, > >I need some help figuring out how to extract combinations of target >words/terms from cancer patient text medical records. I've provided some >sample data and code below to illustr

Re: [R] Extracting sentences with combinations of target words/terms from cancer patient text medical records

2017-07-13 Thread Paul Miller via R-help
tern <- "([^.?!]*(?=[^.?!]*\\bbreast\\b)(?=[^.?!]*\\b(metastatic|stage > IV)\\b)(?=[\\s.?!])[^.?!]*[.?!])" > regmatches(txt, gregexpr(pattern, txt, perl=TRUE, ignore.case=TRUE))[[1]] [1] "Patient had stage IV breast cancer." [2] " Metastatic and breast

[R] R code for if-then-do code blocks

2018-12-17 Thread Paul Miller via R-help
Hello All, Season's greetings! Am trying to replicate some SAS code in R. The SAS code uses if-then-do code blocks. I've been trying to do likewise in R as that seems to be the most reliable way to get the same result. Below is some toy data and some code that does work. There are some thing

Re: [R] R code for if-then-do code blocks

2018-12-19 Thread Paul Miller via R-help
Hi Gabor, Richard, and Thierry, Thanks very much for your replies. Turns out I had already hit on Gabor's idea of "factor out" in writing an initial draft of the code converting from SAS to R. Below is the link Gabor sent describing this and other approaches. https://stackoverflow.com/questio

[R] Running list of drugs taken and dropped (via Reduce and accumulate = TRUE or by other means)

2019-01-10 Thread Paul Miller via R-help
Hello All, Would like to keep a running total of what drugs cancer patients have taken and what drugs have been dropped. Searched the Internet and found a way to cumulatively paste a series of drug names. Am having trouble figuring out how to make the paste conditional though. Below is some s

[R] dplyr: summarise across using variable names and a condition

2021-03-26 Thread Paul Miller via R-help
Hello All, Would like to be able to summarize across in dplyr using variable names and a condition. Below is an example "have" data set followed by an example "need" data set. After that, I've got a vector of numeric variable names. After that, I've got the very humble beginnings of a dplyr-bas

[R] Dynamically defining dplyr across statements (was dplyr: summarise across using variable names and a condition)

2021-03-29 Thread Paul Miller via R-help
quot;{col}_{fn}"   )) %>%   select(starts_with(vars_num) | ends_with("mean")) %>%   rename_at(vars(!starts_with(vars_num)), list(~ str_replace(., "mean$", "prop"))) %>%   all.equal(need) On Friday, March 26, 2021, 1:08:58 p.m. EDT, Rui Barradas wrot