weighted | R Documentation |
A simple class for weighted data.
weighted(x, w)
x |
An atomic vector or |
w |
An numeric vector of weights. |
An object identical to x
but with the additional class
weighted
and a weights
attribute.
x <- c(3.7, 3.3, 3.5, 2.8)
y <- c(1, 2, 1, 2)
w <- c(5, 3, 4, 1)
z <- weighted(x=x, w=w)
weights(z)
weights(z[2:3]) # Weights are preserved
d <- weighted(
data.frame(
x=x,
y=y
),
w
)
weights(d)
weights(d[[1]])
weights(d$x)
weights(subset(d, y==1))
lapply(split(d, d$y), weights)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.