Hello guys, I'm trying to create a sequence of number for each cow. The starting numbers are different by each. The final number is the same which is 305. My questions are: Question1. How can I create a sequence of number for each cows by loop? E_table <- matrix(NA,nrow = nrow(sam_10tdw), ncol = 268, byrow = T) for(i in 1:nrow(sam_10tdw)) { nE <- sam_10tdw[i,c(sam_10tdw$dimEW:305)] E_table[i,] <- nE } E_table <- matrix(NA,nrow = nrow(sam_10tdw), ncol = 268, byrow = T) for(i in 1:nrow(sam_10tdw)) { nE <- seq(sam_10tdw$dimEW, 305, by = 1) E_table[i,] <- nE } These 2 codes didn't work. (using only "nE <- c(sam_10tdw$dimEW:305)" is work for 1 cow) Question2. How can I create matrix to store these sequences which have different columns for each cow. The shortest column length is 145 columns; the longest is 268 columns. I try to assign the longest columns, but not sure if it works as I stuck with an error from question 1. Thanks for your help (Hopefully I wrote it clear enough), Pornpamol This list strives to be beginner friendly. However, we still ask that you PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.