[R] How to delete repeated values in MCMC sampling and get index of unique values?
gunter.berton at gene.com
Thu Jan 17 23:20:38 CET 2013
What answer is wanted for
Note that Duncan's two suggestions below give different answers for this.
On Thu, Jan 17, 2013 at 1:59 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 13-01-17 4:50 PM, C W wrote:
>> Dear list,
>> How do you delete repeated samples? In MCMC, when your candidate value
>> been reject, so you remain on the same point, so you keep that value.
>> Say I have this toy example,
>> The 6 and 4 are repeated, I only want the index of the non-repeated
>> I thought of using which() and unique(), but that does not give you the
>> index of the unique values.
> You could use x[!duplicated(x)] or rle(x)$values, depending on your
> definition of "repeated". I hope you're aware that you can't use either for
> things like quantiles and moments of the limiting distribution.
>> x <- c(1,6,6,6,3,5,4,4,2,3,5)
>  1 6 3 5 4 2
>  1 6 3 5 4 2 3 5
> Duncan Murdoch
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Genentech Nonclinical Biostatistics
Internal Contact Info:
More information about the R-help