[R] Update data in text file with data in dataframe

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sat Aug 19 23:02:08 CEST 2017


You might get someone on this last willing to invent something from scratch, but really this mailing list works best if you give very specific information, such as a verbatim copy of several records worth of your data file including all the stuff you want to skip over. Usually if someone is planning on inventing an example from scratch they make a blog post which you could find via search engine.  Helping you offline is also not preferred since multiple people can offer advice (or correct each other) if you keep the discussion on the list. And no, giving some of the code you have tried is indeed helpful, since it can highlight things you don't know that might seem obvious to us. 

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette)
-- 
Sent from my phone. Please excuse my brevity.

On August 19, 2017 10:39:26 AM PDT, Nic <ncecchino at gmail.com> wrote:
>Hello all,
>
>I'm a novice R programmer and I don't have a clue as to how to approach
>
>this. I have tried many different approaches only to fail and I can't 
>seem to wrap my head around it.  So I turn to the experts.
>
>I have a text file with patient data that has incorrect dates of 
>service.  I need to update the dates of service in the text file with 
>data that's in a dataframe.
>
>Data in the text file looks like this (call it PatRecs):
>
>PatientID #:  12345
>Date of Service:  8/1/2017
>.
>
>.
>
>.
>
>PatientID #:  12346
>Date of Service: 8/2/2017
>
>.
>
>.
>
>.
>
>The dots are other data.  I'm just focused on the PatientID and DOS.
>
>The data in the data frame (call it DF) looks like
>
>Id2    DOS
>
>12345, 8/3/2017
>12346, 8/4/2017
>
>etc.
>
>The lists for both are longer than this.
>
>I know that in programming for this that there should be readLines and 
>writeLines and greps - but I'm far too new to using R to figure out the
>
>usage of these commands.
>
>How can I update the text file (PatRecs) with the incorrect Date of 
>Service, with the correct DOS in the dataframe (DF)???
>
>This is not a homework assignment, I promise.  This is just my attempt 
>to automate data quality using R, and so that I can learn something 
>new.  In any event, providing you with anything I've done so far would 
>be meaningless.  In an effort to minimize email space, please email me 
>directly.  If there is any interest I'll compile the responses and 
>forward them.  I humbly thank you all for any assistance with this.
>
>Best,
>
>Nic
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list