? #rstats friends - I'm trying to copy and insert every value after itself in a vector. Ex:
v1 <- c('a','b')
into
v2 <- c('a','a','b','b')
Would a for loop work instead of multiple instances of:
append(values = v1[1], after = 1) %>%
append(values = v1[2], after = 2) ...
Conversation
Replying to
Someone recommended this:
rep(c("a","b"),20) %>% sort()
[1] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
[40] "b"
Replying to
This is great! I have a vector ~40 characters and need to essentially "duplicate" it from a, b, c, d... to a, a, b, b, c, c, d, d...
This works with a slight modification, swapping the `20` to `2`.
1
2

