Please I am new to R and here as well. I am unable to upload an image of my dataset at the moment.
Here is my problem:
I have a dataset containing two columns that are of particular interest to me. One of them Status
contains identifiers (1 and 2) 1 represents the variable Y1 and 2 represents the variable Y2. I need to run two separate regressions using Y1 and Y2 as dependent variables.
The other column Y1andY2
contains the respective value of Y1 and Y2 all merged into a single column. So I need a way of separating or grouping those values into Y1 and Y2. This would allow me to run the two separate regressions.
Status Y1andY2
1 1.521174
2 1.873917
2 2.116277
1 1.803262
1 3.725778
2 2.285313
1 2.732088
1 2.799842
2 2.976210
1 1.337500
1 1.259238
Your help would be greatly appreciate.
Thanks Cheers Ludov
I think you want to convert your data to wide format so that instead of having a Status ('key') column and a Y1andY2 ('values') column you want one column with the Y1 values and one with the Y2 values. This will make your df have half as many rows.
library(dplyr)
df %>% pivot_wider(names_from = 'Status', values_from = 'Y1andY2')