[R] R match - could be improved ?
J Robertson-Burns
robertsonburns at btinternet.com
Sun Mar 15 18:15:24 CET 2015
I believe that you are in Circle 1 of The R Inferno.
http://www.burns-stat.com/documents/books/the-r-inferno/
Pat
On 15/03/2015 11:04, Jeremy Clark wrote:
> Dear All,
>
> The following gives a very unpleasant experience with apparently random NAs
> - probably it's my bad formatting of the coding - but the effect is
> unexpected and if undetected can lead to considerable problems:
>
> myvector1 = NULL
>
> myvector3 = NULL
>
> myvector4 = NULL
>
> myvector5 = NULL
>
>
>
> myvector1 <- c(1:100)
>
>
>
>
>
> myvector3[[1]] <- seq(myvector1[1], myvector1["length"(myvector1)], by =
> 0.01)
>
> myvector4[[1]] <- seq(95, 100, by = 0.01)
>
>
>
> myvector5[[1]] <- match(myvector4[[1]], myvector3[[1]])
>
>
>
> myvector5
>
>
>
> ## A solution (but rather annoying):
>
>
>
> myvector5[[1]] <- match(as.list(myvector4[[1]]), as.list(myvector3[[1]]))
>
> myvector5
>
> Could anyone tell me why the NAs occur ??
>
> Many thanks.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
More information about the R-help
mailing list