Extract or change the marks attached to vertices or segments of a linear network.
# S3 method for linnet
marks(x, of=c("segments", "vertices"), ...) # S3 method for linnet
marks(x, of=c("segments", "vertices"), ...) <- value
For marks(x)
, the result is a vector, factor or data frame,
containing the mark values attached to the vertices or the
segments of x
.
If there are no marks, the result is NULL
.
For marks(x) <- value
, the result is the updated network
x
(with the side-effect that the dataset x
is updated in
the current environment).
Linear network (object of class "linnet"
).
Character string (partially matched)
specifying whether the marks are attached
to the vertices of the network (of="vertices"
)
or to the line segments of the network (of="segments"
, the default).
Ignored.
Vector or data frame of mark values,
or NULL
.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.
These functions extract or change the marks
attached to the network x
.
They are methods for the generic functions
marks
and
marks<-
for the class "linnet"
of linear networks.
A linear network may include a set of marks attached to the line segments, and a separate set of marks attached to the vertices. Each set of marks can be a vector, a factor, or a data frame.
The expression marks(x, of)
extracts the marks from x
.
The assignment marks(x, of) <- value
assigns new marks to the
dataset x
, and updates the dataset x
in the current
environment.
The argument of
specifies whether we are referring to
the segments or the vertices.
For the assignment marks(x, "segments") <- value
, the value
should be a vector or factor of length equal to the number of
segments in x
, or a data frame with as many rows
as there are segments in x
.
If value
is a single value,
or a data frame with one row, then it will be replicated
so that the same marks will be attached to each segment.
Similarly for marks(x, "vertices") <- value
the number of
marks must match the number of vertices.
To remove marks, use marks(x, of) <- NULL
.
To extract the vertices (including their marks) as a point pattern,
use vertices(x)
. To extract the segments (including their
marks) as a line segment pattern, use as.psp(x)
.
linnet
,
marks
,
marks<-
L <- simplenet
marks(L, "vertices") <- letters[1:nvertices(L)]
marks(L, "segments") <- runif(nsegments(L))
L
marks(L, "v")
marks(L, "s")
Run the code above in your browser using DataLab