I would like to make several lists of numbers and then concatenate them i.e.
list 1 = 1, 1, 1, 1
list 2 = 2, 2, 2, 2
list 3 = 3, 3, 3, 3
final list = 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3
I tried the following to create lists 1 to 3
ageseq <- c(1,2,3)
n <- 3
n2 <- 4
for (i in 1:n){
for (j in 1:n){
age[i] <- c(rep(ageseq[j],n2))
}
}
which produces the following error,
In age[i] <- c(rep(ageseq[j], n2)) :
number of items to replace is not a multiple of replacement length
as age1, age2 and age3 do not exist.
What in my code is missing? In reality I need to concatenate over 70 lists of numbers.
rep(1:3,each=4).ageobject? And what is n2?ageobject should be a list of lengthn2. I would then like to concatenate thesenlists of lengthn2to form a list of length3n2. In realityn2 = >30andn>70.rep(1:3,4)and did not know abouteach.