Sean Davis <[EMAIL PROTECTED]> writes:
> On 2/6/06 5:53 AM, "Piet van Remortel" <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
> >
> > Never really managed to build a for-loop with multiple running
> > variables in an elegant way.
> >
> > Can anybody hint ?
> >
> > See below for an example of what I
ubject: [R] for-loop with multiple variables changing
> Hi all,
>
> Never really managed to build a for-loop with multiple running
> variables in an elegant way.
>
> Can anybody hint ?
>
> See below for an example of what I would like.
>
> EXAMPLE
On 2/6/06 6:23 AM, "Sean Davis" <[EMAIL PROTECTED]> wrote:
>
>
>
> On 2/6/06 5:53 AM, "Piet van Remortel" <[EMAIL PROTECTED]> wrote:
>
>> Hi all,
>>
>> Never really managed to build a for-loop with multiple running
>> variables in an elegant way.
>>
>> Can anybody hint ?
>>
>> See below
If you want a one-to-one action between corresponding pairs of "a" and
"b", then how about simply :
for( i in 1:length(a) ){
print( number[i] )
print( name[i] )
}
If you want the first element of "a" to work with all elements of "b",
the second element of "a" to work with all elements of "b
On 2/6/06 5:53 AM, "Piet van Remortel" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Never really managed to build a for-loop with multiple running
> variables in an elegant way.
>
> Can anybody hint ?
>
> See below for an example of what I would like.
>
> EXAMPLE
> a<-c(1,2,3)
> b<-c("name1","n
Hi all,
Never really managed to build a for-loop with multiple running
variables in an elegant way.
Can anybody hint ?
See below for an example of what I would like.
EXAMPLE
a<-c(1,2,3)
b<-c("name1","name2","name3")
for( number in a, name in b ) {
print( number ) ##take a value