Sorry for a slightly unhelpful title, my question is a little difficult to explain. I have some data with the following general format:
y <- c(0,10,10,4,8,9,2,10,7,1,3,1)
node <- c(rep(1,6), rep(2,6))
d <- data.frame(
X = X,
Y = Y,
node = node
)
Where Y
is the "outcome", node is a grouping variable and X
is a timecode. What I need to do is, for each Node individually, transform the 6 corresponding values in the X
column to 1 - 6 where 1 is assigned the smallest number in X
and 6 to the largest number in X
. Basically, label them 1-6 in ascending order.
To be clear, simply assigning 1 - 12 based on the order of the X
column and ignoring the node
column would not achieve what I need it to. Likewise, its vital that the pairings between node
X
and Y
remain in tact after transformation.
Many thanks in advance.