Hi All,
Just yesterday, user 'nwerth' suggested a very helpful insight for using the 'lapply' function to assign dichotomous values to a dataset with six prospective values, and five variables.
In such circumstances, I had suggested that I had a data set called 'trial' with five variables ("L", "M", "N", "O", "P") with six levels (0,1,2,3,4,5,), which I wished to dichotomise: 0 = {0,1,2}, 1 = {2,3,4,5}.
trial[] <- lapply(trial, factor, levels = 0:5, labels = c(1, 1, 1, 2, 2, 2))
Yet, suppose now that some of variables in my data set did not have six levels, but instead had three levels: {1,2,3}.
It follows, that if I wished to dichotomised L = 0 = {0,1,2}, 1 = {2,3,4,5}, yet also wished to dichotomise M,N,O,P = 0 = {1}, 1 = {2,3}, that there would be multiple matchings for zero = {0,1,2} and {1}.
I wondered therefore if anyone knew how to overcome this problem and code variables with values which are independently?
Would be appreciated.
Best,
Andrew