[R] string
(Ted Harding)
Ted.Harding at manchester.ac.uk
Sat Aug 1 00:31:19 CEST 2009
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.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 31-Jul-09 Time: 23:31:17
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list