Hi Jorge and R users 
 
Thank you so much for the responses. You input helped me alot and
potentially can help me to solve one more problem, but I got error message.
I am sorry to ask you again but if you can find my problem in quick look
that will be great. I hope this will not cost alot of your time as this is
based on your idea. 
 
# Just data 
X1 <- c(1,3,4,2,2)
X2 <- c(2,1,3,1,2)
X3 <- c(4,3,2,1,1)
X4<- c(1,1,1,2,3)
X5 <- c(3,2,1,1,2)
X6 <- c(1,1,2,2,3)
odataframe <- data.frame(X1,X2,X3,X4,X5,X6)
 
My objective here is sort the value of the pair of variables (X1 and X2, X3
and X4, X5 and X6 and so on.........)  in such way that the second column in
pair is always higher than the first one (X2 > X1, X4 > X3, X6> X5 and so
on.......). 
 
Here is my attempt: 
nmrk <- 3
nvar <- 2*nmrk 
lapply(1:nvar, function(ind){
# indices for the variables we need
 a <- seq(1, nvar, by = 2)
 b <- seq(2, nvar, by = 2)
# shorting column
tx[, a[ind]] = ifelse(odataframe[, a[ind]] < odataframe[,b[ind]],
odataframe[, a[ind]], odataframe[, b[ind]])
tx[, b[ind]] = ifelse(odataframe[, b[ind]] > dataframe[,a[ind]],
odataframe[,b[ind]], odataframe[,a[ind]])
df1 <- transform( odataframe, odataframe[, a[ind]]= tx[, a[ind]],
odataframe[, b[ind]]= tx[, b[ind]]))
}
 
I got the following error: 
Error:
Error: unexpected '=' in:
"tx[, b[ind]] = ifelse(odataframe[, b[ind]] > dataframe[,a[ind]],
odataframe[,b[ind]], odataframe[,a[ind]])
df1 <- transform( odataframe, odataframe[, a[ind]]="
 
Thanks;
Umesh R 


	[[alternative HTML version deleted]]

