Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206255

Alternate elements of a vector with multiple NAs

$
0
0

I have a character vector in R, and want to make a new vector with multiple NAs between the elements of the character vector. To simplify, the character vector is:

cv <- c( "A", "B", "C" )

Let's say we just want 3 NAs (actually need much more). Desired output vector would be:

"A", NA, NA, NA, "B", NA, NA, NA, "C", NA, NA, NA

I'm guessing this has been asked before, but it's very difficult to search for. I've tried various permutations and combinations of rep and rbind with no success. Be gentle; my first question :-)


Viewing all articles
Browse latest Browse all 206255

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>