rregressioneconomics

Separating or grouping Values of a column into different categories in R


screenshot of the Dataset

Good morning everyone. Please I do have a problem that I have not been able to solve for quite some time now.(please take a look at the image link to see a screen shot of my data set) https://i.sstatic.net/g2eTM.jpg

I have a column of data (status) containing two set of values (1 and 2). These are dummies representing two categories (or status) of dependent Variables (say Pp and Pt) that I need for a regression. their actual values are contained the last column Pp.Pt (Pp.Pt is just a name nothing more).

I need to run two separate regressions each using either Pp or Pt (meaning using their respective values in the Pp.Pt column (each value in the last column is either of status 1 or of status 2) . **My question is How do I separte them or group them into these two categories 1= Pp and 2 = Pt so that i could clearly identitify and group them.

https://i.sstatic.net/g2eTM.jpg

Thank you very much for your kind help. Best Ludovic


Solution

  • this approach can fix your issue

    yourdata %>%
    mutate(classofyourcolumn=ifelse(columntosplit<quantile(columntosplit,0.5),1,0))