[R] dim vector or data.frame

Berry Boessenkool berryboessenkool at hotmail.com
Fri Feb 14 16:26:03 CET 2014


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 then with the following code?

if( if(is.vector(input)) length(input)>1  else nrow(input)>1  )  ...

thanks ahead,
Berry 		 	   		  


More information about the R-help mailing list