Trying to put together a loop for my reproducible example.
for (i in c(2006,2008,2010,2012)) {
UniqueID <- 1:10 # <- Not all numeric - Kept as character vector
Name <- LETTERS[seq( from = 1, to = 10 )]
Entity_Type <- factor("This","That")
Data1 <- rnorm(10)
Data2 <- rnorm(10)
Data3 <- rnorm(10)
Data4 <- rnorm(10)
Year <- i
x[i] <- data.frame(UniqueID, Name, Entity_Type, Data1, Data2, Data3, Data4, Year)
}
and now the error is:
Error in `[<-.data.frame`(`*tmp*`, i, value = list(UniqueID = 1:10, Name = 1:10, :
new columns would leave holes after existing columns
How can I format this so that it can take that value for the year?
Thanks!