[R] Scalar vs. vector

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 8 14:09:57 CEST 2003

On Mon, 7 Apr 2003, Chris Fehily wrote:

> Do these statements yield identical types of objects?
>    x = 3
> and
>    y = c(3)
> That is, intrinsically, is x, like y, a vector of length one, but created 
> with abbreviated syntax?

Yes.  c() is a function which here is doing nothing useful.

> More simply: Are scalars really trivial vectors?

Thare are no scalar variables in S.  Since there are vectors of length 
zero, those of length one are not `really trivial' in comparison.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list