I have a case where the variable names in my dataframes contain information about more than one variable. For example, "cs_ta_p50". I used melt
to melt the data. So now I have
|variable value |
|cs_ta_p50 ... |
To fix this I need to create a variable ''type'' and ''dec''
I try to do this by:
cbind(mdata, colsplit(mdata$variable,"(\\_p50)", names=c("type","dec")))
But this results in
|variable value type dec |
|cs_ta_p50 ... cs_ta NA |
when I really need
|variable value type dec |
|cs_ta_p50 ... cs_ta p50|
I guess this has to do with the regular expression being wrong, so what do I do?