HI, For the first question: you could do, ?vec1 <- c(rep(0:4,each=5),rep(0:4,5:1)) as.vector(tapply(vec1,cumsum(abs(c(0,diff(vec1)))),FUN=paste,collapse="")) # [1] "00000" "11111" "22222" "33333" "44444" "00000" "1111"? "222"?? "33"?? #[10] "4"??? Second question is not clear.? May be this link helps. http://stackoverflow.com/questions/17179047/finding-the-set-of-n-equally-distant-points A.K. Hey all am a bit of a newbie in R and have a couple of rather basic code resquests 1.How do I get this output from R ie 00000 11111 22222 33333 44444 00000 1111 222 33 4 2.a vector of n ie 10 values(equidistant) btwn any two values ie 22 and 23