I have a scenario I am facing.
I need to Export a Pipe Delimited Text File From R with a header and trailer.
Due to the sensitivity of the data, I am working with, I provided a mock of what could be done with the output below.
employee <- c('John Doe','Peter Gynn','Jolie Hope')
salary <- c(21000, 23400, 26800)
startdate <- as.Date(c('2010-11-1','2008-3-25','2007-3-14'))
employ.data <- data.frame(employee, salary, startdate)
The DF created the following output:
employee salary startdate
John Doe 21000 2010-11-01
Peter Gynn 23400 2008-03-25
Jolie Hope 26800 2007-03-14
code used to export the DF as a pipe delimited file:
write_delim(employ.data, file = "EIN01_Pipe_delimited.txt", delim = "|")
I believe I am close as when I used the code above export the DF to a pipe delimited format, I get the following:
What I need is below in which you will see it shows the header, name, number of rows. Then the body displays all of the columns followed by all the rows of data.
Patient ID - Pharmacy|Patient Gender|Patient Ethnicity|PHI Consent?|Patient State|Patient Birth Year|Patient Height|Patient Weight|PHI Consent Date|Patient MRN|Patient Phone - Pri|Patient Phone - Sec|Patient SSN|Patient Email|Patient Hub ID|Patient Last Name|Patient First Name|Patient Address1|Patient Address2|Patient City|Patient Postal Code|Patient Birth Date
Z1079321|M|6||MN|1979||||00961922||||||Ruth|Babe|2625 1ST AVE||Warroad|54321|19791004
Z1089101|F|6||MN|1984||||00838657||||||Gehrig|Lou|241 FAIR RD||Roseau|54322|19840716
Z1090762|F|6||MN|1957||||01432021||||||Cobb|Ty|2717 MAIN Rd.|#17|Baudette|54333|19571012
I think I am very close, but I am missing some last key parts.
Is there anyone that could help me round out this task?
All the help is greatly appreciated.