Re: [R] reverse vector elements

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Tue, 12 Feb 2008 10:49:46 -0200

rev(1:10)

On 12/02/2008, mohamed nur anisah <nuranisah_mohamed_at_yahoo.com> 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 my output to be like this:
> y
> [1] 10 9 8 7 6 5 4 3 2 1
>
> Any suggestion?? Thanks!!
> Cheers,
> Anisah
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 12 Feb 2008 - 12:56:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 12 Feb 2008 - 13:30:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive