[R] parsing text files
biino at igm.cnr.it
Thu Mar 8 14:10:36 CET 2012
Hello, I have a .txt file with many clinical exams reports (two examples of
which are attached to the message).
I have to create a data frame with as many rows as the number of clinical
exams reports in the text file and 24 columns:
the first (to be labelled as "ID") with a number (representing an
identification code) which is the number in the 13th line of the clinical
report following the string "Acc.ne n. "
the second (to be labelled as "DATE") with a date (indicating date of blood
sampling), which is the date, again in the 13th line, following the
the following 22 columns (to be labelled with the name of parameters at
lines from 20 to 41, as "GLICEMIA" ... "COLESTEROLO LDL")
I did search in the mailing list and tried to begin something like:
#read the text file
reports <- readLines("ClinicalReports.txt")
#processing the file starting at each "Acc.ne n. "
serologic <- lapply(which(grepl("^Acc.ne n.", reports)), function(.line
but I'm a biostatistician whith almost no expertise in programming and I
really need your hepl! Please!!!
View this message in context: http://r.789695.n4.nabble.com/parsing-text-files-tp4456355p4456355.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help