On 31-Jul-09 22:10:46, Mohsen Jafarikia wrote: > Hello All: > I am wondering how I can have "dat1" and "dat2" in the following > loop where 'dat' and 'i' stick together to make dat1 and dat2 : > > ifn <- "MyData" > dat <- read.table(ifn) > > MyData: > 01 0.40 > 02 0.40 > 03 0.40 > 04 0.35 > 05 0.34 > 06 0.33 > > names(dat)<-c("Code","M") > for(i in 1:2) > { > dati <- dat[i:i+2,] > }
Try using paste(): for(i in (1:2)){ print(paste("dat", i, sep="")) } See '?paste' Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 31-Jul-09 Time: 23:31:17 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@r-project.org mailing list 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.