Skip to content
Back to formatted view

Raw Message

Message-ID: <OFD888D627.4CB11008-ON802574C7.00510024-802574C7.005169D9@hsl.gov.uk>
Date: 2008-09-17T14:51:58Z
From: Richard Cotton
Subject: using for variable as rowname
In-Reply-To: <19533203.post@hsl.gov.uk>

> Is there a way to use the cycle variable for rowname?
> 
> v=1:6
> for (a in 1:3){
>  for  (b in 4:5) {
>   v=rbind(v,a.b=1)
>  }
> }
> v
> 
> This above obviously does not work, but I couldn't find out how to use a 
and
> b to construct a rowname like 14, 15, 24, 25.

Not pretty, but this does the trick.

v=1:6
nam <- "?"
for (a in 1:3){
   for  (b in 4:5) {
      v <- rbind(v,1)
      nam <- c(nam, paste(a,b,sep="."))
   }
}
rownames(v) <- nam
v

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}