within-operators | R Documentation |
The operators %$%
and %$$%
provide
abbrevitions for calls to with()
and within()
respectively.
The function Within()
is a variant of with()
were
the resulting data frame contains any newly created variables in the
order in which they are created (and not in the reverse order).
data %$% expr
data %$$% expr
Within(data,expr,...)
## S3 method for class 'data.frame'
Within(data,expr,...)
data |
a data frame or similar object, see |
expr |
a single or compound expression (i.e. several expressions
enclosed in curly braces), see |
... |
Further arguments, currently ignored |
with
and within
in package "base".
df <- data.frame(a = 1:7,
b = 7:1)
df
df <- within(df,{
ab <- a + b
a2b2 <- a^2 + b^2
})
df
df <- data.frame(a = 1:7,
b = 7:1)
df <- Within(df,{
ab <- a + b
a2b2 <- a^2 + b^2
})
df
df <- data.frame(a = 1:7,
b = 7:1)
df
ds <- as.data.set(df)
ds
df %$$% {
ab <- a + b
a2b2 <- a^2 + b^2
}
df
ds %$$% {
ab <- a + b
a2b2 <- a^2 + b^2
}
ds
df %$% c(a.ssq = sum(a^2),
b.ssq = sum(b^2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.