I am trying to insert multiple elements into a vector each in different places. This is an example followed by a series of tests that do not work.
w <- c( 1,3,2,4,2,3,2,4,5,7,9,3,2,4,2,5,7,4,2 )
u <- c( 3,7,9,12 )
o <- c( 10 , 20 , 30 , 40 )
I tried:
append ( w , o , after = u )
fun <- function (x) append ( w , o[[x]] , after = u[[x]] )
lapply ( seq ( length ( u )) , fun )
for (i in length(o)) {
append ( w , o[[i]] , after = u[[i]] )
}
Desired output
1,3,2,10,4,2,3,2,20,4,5,30,7,9,3,40,2,4,2,5,7,4,2
Is there a way to insert each item one at a time in a particular location? I saw several questions regarding the basic append element for one element with one location or two elements that should be added to the same position, but not for adding several elements to several locations in the vector.