Re: [R] reverse vector elements

2008-02-12 Thread Gavin Simpson
On Tue, 2008-02-12 at 04:47 -0800, mohamed nur anisah wrote: > Dear lists, > > I want to write a function of a vector and reverse the order of its > elements. Here is my code: > > revector<-function(n){ > y=vector(length=n) > for(i in n:1){ > y[i]=i > } > return(y) > } >

Re: [R] reverse vector elements

2008-02-12 Thread Henrique Dallazuanna
rev(1:10) On 12/02/2008, mohamed nur anisah <[EMAIL PROTECTED]> wrote: > Dear lists, > > I want to write a function of a vector and reverse the order of its > elements. Here is my code: > > revector<-function(n){ > y=vector(length=n) > for(i in n:1){ > y[i]=i > } > return(y) > } >

Re: [R] reverse vector elements

2008-02-12 Thread Chuck Cleland
On 2/12/2008 7:47 AM, mohamed nur anisah wrote: > Dear lists, > > I want to write a function of a vector and reverse the order of its > elements. Here is my code: > > revector<-function(n){ > y=vector(length=n) > for(i in n:1){ > y[i]=i > } > return(y) > } > > i want m

[R] reverse vector elements

2008-02-12 Thread mohamed nur anisah
Dear lists, I want to write a function of a vector and reverse the order of its elements. Here is my code: revector<-function(n){ y=vector(length=n) for(i in n:1){ y[i]=i } return(y) } i want my output to be like this: y [1] 10 9 8 7 6 5 4 3 2 1 Any