Re: [R] print vectors with consecutive numbers

2014-08-22 Thread Bert Gunter
n you have not made an honest effort to learn. And if you have already, post away. Cheers, Bert > > Cheers. > > James > > From: jorgeivanve...@gmail.com > Date: Fri, 22 Aug 2014 22:28:40 +1000 > Subject: Re: [R] print vectors with consecutive numbers > To: zwei0...@hotma

Re: [R] print vectors with consecutive numbers

2014-08-22 Thread James Wei
Hi Jorge, Thanks so much, it is working perfectly. There are so many for me to learn. Cheers. James From: jorgeivanve...@gmail.com Date: Fri, 22 Aug 2014 22:28:40 +1000 Subject: Re: [R] print vectors with consecutive numbers To: zwei0...@hotmail.com CC: r-help@r-project.org Hi James

Re: [R] print vectors with consecutive numbers

2014-08-22 Thread Jorge I Velez
Hi James, Try mat[, apply(mat, 2, function(x) any(diff(x) == 1))] HTH, Jorge.- On Fri, Aug 22, 2014 at 10:18 PM, James Wei wrote: > > > Hi all, > > I have a matrix with consecutive and non-consecutive numbers > in columns. For example, the first 2 columns have consecutive numbers. I > want

[R] print vectors with consecutive numbers

2014-08-22 Thread James Wei
Hi all, I have a matrix with consecutive and non-consecutive numbers in columns. For example, the first 2 columns have consecutive numbers. I want R to print only columns with consecutive numbers. Here is the matrix and how I did using conditional statement: ## mat=matrix(data=c(9,2,3,4,5,6,1