Re: [R] dim vector or data.frame

2014-02-14 Thread Bert Gunter
Yes. And there's also a possibility of keeping the vector as a one column data frame (using a drop=FALSE argument in indexing to avoid conversion to vectors perhaps) so that nrow() can be used. This has the disadvantage of the inefficiency of using a data frame when a vector will do, and the advan

Re: [R] dim vector or data.frame

2014-02-14 Thread Jorge I Velez
Hi Berry, What about using NROW(input) ? Best, Jorge.- On Sat, Feb 15, 2014 at 2:26 AM, Berry Boessenkool < berryboessenk...@hotmail.com> wrote: > Hi, > > In my function, I want to allow input to be a vector or a data.frame. > Certain operations need to be done if the length or nrows exceeds

[R] dim vector or data.frame

2014-02-14 Thread Berry Boessenkool
Hi, In my function, I want to allow input to be a vector or a data.frame. Certain operations need to be done if the length or nrows exceeds one, but since "nrow" doesn't work for vectors, I cannot simply use if( nrow(input)>1 | length(input)>1 ) ... So is there a more elegant way to do this the