[R] why should you set the mode in a vector?

2004-10-29 Thread Joel Bremson
Hi all, If I write v = vector(mode="numeric",length=10) I'm still allowed to assign non-numerics to v. Furthermore, R figures out what kind of vector I've got anyway when I use the mode() function. So what is it that assigning a mode does? Joel __

Re: [R] why should you set the mode in a vector?

2004-10-29 Thread Peter Dalgaard
Joel Bremson <[EMAIL PROTECTED]> writes: > Hi all, > > If I write > > v = vector(mode="numeric",length=10) > > I'm still allowed to assign non-numerics to v. Not without changing the mode of v or the right hand side: > v = vector(mode="numeric",length=10) > v[3] <- T > v [1] 0 0 1 0 0 0 0 0

Re: [R] why should you set the mode in a vector?

2004-10-29 Thread Tony Plate
It's useful when you need to be certain of the mode of a vector. One such situation is when you are about to call a C-language function using the .C() interface. As you point out, some assignments (even just to vector elements) can change the mode of the entire vector. This is why it's impor