[R] x[c(1,2,1)] <- 1:3
Simon Fear
Simon.Fear at synequanon.com
Fri Oct 24 11:31:35 CEST 2003
?order descending in means "order" assume always you Do
> -----Original Message-----
> From: Robin Hankin [mailto:rksh at soc.soton.ac.uk]
> Sent: 24 October 2003 10:18
> To: r-help at stat.math.ethz.ch
> Subject: [R] x[c(1,2,1)] <- 1:3
>
>
> Security Warning:
> If you are not sure an attachment is safe to open please contact
> Andy on x234. There are 0 attachments with this message.
> ________________________________________________________________
>
> Hi everyone.
>
> look at this:
>
> x <- 1:4
> x[c(1,2,1)] <- (1:3)
> print(x[1])
>
> I get 3, but isn't NA more appropriate? [1 would be as sensible].
> FWIW, the equivalent Fortran 95 statement is flagged as an error.
> R-intro, section 2.7, says that in such cases the assignment is
> carried out "in order" which might support getting 3.
>
> To my way of thinking, the concept of "in order" seems to violate the
> usual strategy of considering vectors as whole entities---because in
> this case we have to specify whether the assignment starts at
> c(1,2,1)[1] and proceeds to c(1,2,1)[3], or starts at c(1,2,1)[3] and
> proceeds to c(1,2,1)[1]. And the results are different!
>
>
> What is the R position on this?
>
>
> rksh
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: Simon.Fear at synequanon.com
web: http://www.synequanon.com
Number of attachments included with this message: 0
This message (and any associated files) is confidential and\...{{dropped}}
More information about the R-help
mailing list