[R] Is k equivalent to k:k ?
Liaw, Andy
andy_liaw at merck.com
Mon Aug 2 17:08:30 CEST 2004
See ?":", especially the `Value' section. Numeric literals in R is double
by default.
Andy
> From: Georgi Boshnakov
>
> Hi,
>
> I wonder if the following (apparent) inconsistency is a bug
> or feature.
> Since scalars are simply vectors of length one I would think that
> a and
> a:a
> produce the same result. For example,
>
> > identical(4.01,4.01:4.01)
> [1] TRUE
>
> However,
>
> identical(4,4:4)
> [1] FALSE
>
> and
>
> > identical(4.0,4.0:4.0)
> [1] FALSE
>
> A closer look reveals that the colon operator produces
> objects of different class, e.g.
>
> > class(4)
> [1] "numeric"
> > class(4.0)
> [1] "numeric"
>
> but
>
> > class(4:4)
> [1] "integer"
> > class(4.0:4.0)
> [1] "integer"
>
>
> Georgi Boshnakov
>
> --------------------------------------------------------------
> ----------------
> Dr Georgi Boshnakov tel.: +44
> (0)161 200 3684
> Mathematics Department email:
> georgi.boshnakov at umist.ac.uk
> UMIST
> P O Box 88
> Manchester M60 1QD
> UK
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list