| Colon | R Documentation |
Generate regular sequences.
from:to a:b
from | starting value of sequence. |
to | (maximal) end value of the sequence. |
a, b |
|
The binary operator: has two meanings: for factorsa:b isequivalent tointeraction(a, b) (but the levels areordered and labelled differently).
For other argumentsfrom:to is equivalent toseq(from, to),and generates a sequence fromfrom toto in steps of1or-1. Valueto will be included if it differs fromfrom by an integer up to a numeric fuzz of about1e-7.Non-numeric arguments are coerced internally (hence withoutdispatching methods) to numeric—complex values will have theirimaginary parts discarded with a warning.
For numeric arguments, a numeric vector. This will be of typeinteger iffrom is integer-valued and the resultis representable in theR integer type, otherwise of type"double" (akamode"numeric").
For factors, an unordered factor with levels labelled asla:lband ordered lexicographically (that is,lb varies fastest).
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.
(for numeric arguments: S does not have: for factors.)
seq (ageneralization offrom:to).
As an alternative to using: for factors,interaction.
For: used in the formal representation of an interaction, seeformula.
1:4pi:6 # real6:pi # integerf1 <- gl(2, 3); f1f2 <- gl(3, 2); f2f1:f2 # a factor, the "cross" f1 x f2
Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.
