#R version 3.3.2 x = sample(c(LETTERS, letters, 0:9), 12, replace = TRUE ) for (i in c(5,10)) { x <- c(x[1:i-1] ,'\n',x[i:length(x)]) } x <- c(x, '\n') cat(paste(x, collapse = ''))