[R] Simple... but...
Ben Bolker
bolker at ufl.edu
Wed Jul 23 16:05:35 CEST 2008
Doran, Harold <HDoran <at> air.org> writes:
>
> Shubba
>
> I'm confused. Your first post said the result should be c(1,2,3,4,5,6)
> when x and y are combined. The code I sent does that. But here you say
> your result should be c(4,1,2,5,2,3).
>
> What do you want your result to actually be?
>
I think he wants
x = c(4,2,5)
y = c(1,5,3)
c(rbind(x,y))
[1] 4 1 2 5 5 3
Or less cryptically/magically:
n <- length(x)
z <- numeric(2*n)
z[seq(1,2*n,by=2)] <- x
z[seq(2,2*n,by=2)] <- y
Ben Bolker
More information about the R-help
mailing list