I have several sets of columns whose names are related. For example, in the toy DATA
below, one set of variables start with OTE_
and another set of variable start with RAE_
.
In my actual data, I have several more set of these similarly named variables. But as a starting point, I’m wondering how I can reformat my DATA
so that I achieve my Desired_output
below.
DATA <- read.table(header=T, text=
"InstNm OTE_CPct OTE_L OTE_P OTE_R RAE_EPct RAE_NPct RAE_L RAE_B RAE_P RAE_R
Baker 60 1 1 Limited 56 76 1 0 1 Limited")
Desired_output <- read.table(header=T, text=
"InstNm Indicator Rating Pct L P B
Baker OTE Limited 60 1 1 NA
Baker RAE Limited 95 1 1 0")