Re: [R] pairing columns based on a value

2014-12-18 Thread Chel Hee Lee
I do not think that you need regular expressions for your problem. Please see the below: > d0 <- dat_unmatched > tmp <- apply(d0, 1, function(x){ + first <- substr(x,1,1) + idx <- which(c("T", "Y") == first) + comb <- paste(x[idx[1]-1], x[idx], collapse=" ") + unlist(strsplit(comb, " ")) + }) >

Re: [R] pairing columns based on a value

2014-12-18 Thread Michael Dewey
Not sure how much help it will be but there is a package on CRAN called icd9. Although clearly the codes are different in ICD 10 it may give you some hints. I suppose you could even email the maintainer to see whether there is an icd10 in the pipeline. On 17/12/2014 20:14, Robert Strother wrot

Re: [R] pairing columns based on a value

2014-12-17 Thread Bert Gunter
"out of your depth" does not serve as a legitimate excuse -- for me anyway. There are many good tutorials on regular expressions out there. Go through one. Ditto with R data handling. "An Introduction to R" (ships with R) is one that's right at hand. Although others may be more inclined than I am

[R] pairing columns based on a value

2014-12-17 Thread Robert Strother
I have a large dataset (~50,000 rows, 96 columns), of hospital administrative data. many of the columns are clinical coding of inpatient event (using ICD-10). A simplified example of the data is below > dput(dat_unmatched) structure(list(ID = structure(c(4L, 3L, 2L, 1L), .Label = c("BCM3455", "BZD