Skip to content

Instantly share code, notes, and snippets.

@tdsmith
Created February 27, 2015 20:48
Show Gist options
  • Save tdsmith/7975fbc2fca07f2b0026 to your computer and use it in GitHub Desktop.
Save tdsmith/7975fbc2fca07f2b0026 to your computer and use it in GitHub Desktop.
> a
[1] 1 2 3 4
> b
[1] -1
> c = rep(a, each=2)
> c
[1] 1 1 2 2 3 3 4 4
> c[seq.int(from=2, to=length(c), by=2)] = b
> c[1:length(c)-1]
[1] 1 -1 2 -1 3 -1 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment