• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Starting with incomplete cycle in rep()

Resolved: Starting with incomplete cycle in rep()

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I want to generate a sequence where in a first step a random start number is chosen. Depending on the random start number (let’s say: start_number = 3) I want to generate the following sequence. How can I do this?
if you want integers:
Edit:
Since you said your start is random, here is a code to do this:

seq_length <- 4 start_number <- sample(seq_length, 1) b <- start_number:seq_length rep(c(b, setdiff(1:seq_length, b)), each = 2, length=100) [1] 2 2 3 3 4 4 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4 .... [/code]

If you have better answer, please add a comment about this, thank you!

r
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Sort dataframe columns value by close it to another column

27/03/2023

Resolved: PostgreSQL resample 1 minute OHLCV candle data into 5 minute OHLCV candle data

27/03/2023

Resolved: How do I navigate a table without any easily accessible distinctions?

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.