[R] R match - could be improved ?

Michael Dewey info at aghmed.fsnet.co.uk
Sun Mar 15 18:24:55 CET 2015


Dear Jeremy

The NAs do not seem random to me as the gaps between successive NAs are 
either 3, 8 or 11.

Have you considered the possibility that the finite precision of real 
numbers in computers may be the issue here?

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.
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2015.0.5751 / Virus Database: 4306/9307 - Release Date: 03/15/15
>

-- 
Michael
http://www.dewey.myzen.co.uk



More information about the R-help mailing list