Hi EverybodyI am trying to make an object with length(a) * length(b) element using a double loop. But I am getting the last part only. A simple script is a <- c("A-AA", "B-BB", "C-CC") b <- seq(1, 5) pre <- NULL post <- NULL page <- NULLfor(j in 1:length(a)) { for(i in 1:length(b)){ pre[j] <- strsplit(a[j],"-")[[1]][1] post[j] <- strsplit(a[j],"-")[[1]][2] page[i] <- paste0(pre[j], b[i],post[j]) }}Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.