Is there a method to generate random integers in R such that any two consecutive numbers are different? It is probably along the lines of x[k+1] != x[k]
but I can't work out how to put it all together.
相关问题
- Do the Java Integer and Double objects have unnece
- R - Quantstart: Testing Strategy on Multiple Equit
- Using predict with svyglm
- Reshape matrix by rows
- Extract P-Values from Dunnett Test into a Table by
相关文章
- How to convert summary output to a data frame?
- How to plot smoother curves in R
- Paste all possible diagonals of an n*n matrix or d
- ess-rdired: I get this error “no ESS process is as
- How to use doMC under Windows or alternative paral
- dyLimit for limited time in Dygraphs
- Given a list and a bitmask, how do I return the va
- Saving state of Shiny app to be restored later
Not sure if there is a function available for that. Maybe this function can do what you want:
Example:
Hope this helps.
The function above has a long worst-case runtime. We can keep that worst-case more constant with for example the following implementation:
Another approach is to over-sample and remove the disqualifying ones as follows: