ok found a solution (for those who might have a similar problem in the future)
in the sample data below, I assume that columns 2 and 3 must remain, while columns 4-6 need to be transposed.
I used the "unstack" which made the task pretty easy, probable there is an even easier way around this, but this worked quite ok for me, so I ll just leave it there.
create data
x <- data.frame("SN" = 1:24, "Tube" = c(1,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,5),
"Name" = c("John","John","John","John","John","John","John","John","Dora","Dora","Dora","Dora","Dora","Dora","Dora","Dora","Nick","Nick","Nick","Nick","Nick","Nick","Nick","Nick"))
x$CP1 <- sample(40, size = nrow(x), replace = TRUE)
x$CP2 <- sample(40, size = nrow(x), replace = TRUE)
x$CP3 <- sample(40, size = nrow(x), replace = TRUE)
conversion
tmp1 <- data.frame(CP1=x$CP1, ind=rep(1:8, nrow(x)/8))
tmp2 <- data.frame(CP2=x$CP2, ind=rep(1:8, nrow(x)/8))
tmp3 <- data.frame(CP3=x$CP3, ind=rep(1:8, nrow(x)/8))
new1=unstack(tmp1, CP1~ind)
new2=unstack(tmp2, CP2~ind)
new3=unstack(tmp3, CP3~ind)
z=unique(x[2:3])
tmp1=cbind(z,new1)
tmp2=cbind(z,new2)
tmp3=cbind(z,new3)
new.data=rbind(tmp1,tmp2,tmp3)