What Does the @ Symbol Mean in R

What does the @ symbol mean in R?

See ?'@':

  • Description:

    Extract the contents of a slot in a object with a formal (S4)
    class structure.

  • Usage:

    object@name

    ...


The S language has two object systems, known informally as S3 and S4.

  • S3 objects, classes and methods have been available in R
    from the beginning, they are informal, yet very interactive.
    S3 was first described in the White Book (Statistical Models in S).
  • S3 is not a real class system, it mostly is a set of naming
    conventions.
  • S4 objects, classes and methods are much more formal and
    rigorous, hence less interactive. S4 was first described
    in the Green Book (Programming with Data). In R it is
    available through the methods package, attached by default
    since version 1.7.0.

See also this document: S4 Classes and Methods.

What is the symbol ~ for in R?

R supports a special data type called "formula", which has the general form

LHS ~ RHS

although LHS is not always required. There are rules for how to specify the LHS and RHS and what they mean (see ?formula).

The interpretation of a formula depends on the function call, so you need to read the documentation for the specific call. For example, in

aggregate(mpg~cyl,mtcars,mean)
# cyl mpg
# 1 4 26.66364
# 2 6 19.74286
# 3 8 15.10000

the formula means "group mpg by cyl in mtcars and calculate the mean for each group".

On the other hand, when used in lm(...)

fit <- lm(mpg~wt+hp+disp,mtcars)
summary(fit)
# ...
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 37.105505 2.110815 17.579 < 2e-16 ***
# wt -3.800891 1.066191 -3.565 0.00133 **
# hp -0.031157 0.011436 -2.724 0.01097 *
# disp -0.000937 0.010350 -0.091 0.92851
# ---
# ...

means "fit a linear model mpg = b0 + b1*wt + b2*hp + b3*disp". Note that you don't specify the b's.

In xyplot(...)

library(lattice)
xyplot(mpg~wt,mtcars)

the formula means "plot mgp vs wt in mtcars".

Finally, you can set a variable to a formula, as in

myFormula <- mpg~hp+wt+disp
fit <- lm(myFormula,mtcars)

Meaning of Symbol % % in R

%>% means whatever you want it to mean, in Base R anyway:

> %>%
Error: unexpected SPECIAL in "%>%"

(which means that symbol is not defined.)

Binary operators are ones that have an input from the left and from the right of the operator, just like *, + etc. You use them as you would mathematically like a * b, which R turns into the call '*'(a, b). R allows you to add your own binary operators via the %foo% syntax, with foo replace by whatever you want, as long as it hasn't already been used by R, which includes %*% and %/% for example.

`%foo%` <- function(x, y) paste("foo", x, "and foo", y)

> 1 %foo% 2
[1] "foo 1 and foo 2"

%>% takes on a specific and well-defined meaning once you load the magrittr R package for example, where it is used as a pipe operator might be in a Unix shell to chain together a series of function calls.

What does the symbol ::: mean in R

From the help file (you can see this with help(":::")):

The expression 'pkg::name' returns the value of the exported
variable 'name' in package 'pkg' if the package has a name space.
The expression 'pkg:::name' returns the value of the internal
variable 'name' in package 'pkg' if the package has a name space.

In other words ::: is used to directly access a member of a package that is internal (i.e. not exported from the NAMESPACE).

See this related question: R: calling a function from a namespace.

What does this R symbol mean?

I just ran the topic model without issue. I think this symbol suggests that the cell contains a large text (e.g., pages of words). Thank you all for your help!

what does at sign @ stand for in R?

S4 objects are lists with nodes or leaves (which are technically calls 'slots') that are accessible with the @ operator just as S3 objects are accessed with $.

Take a look at:

str( perf1@x.name )
str( perf1@y.name )

Notice that these may contain ordinary S3 lists as with:

str( perf1 @ x.values) # a list
str( perf1 @ x.values[[1]] ) # a numeric vector
perf1 @ x.values[[1]][1] # the first value in `x.values`

It's considered poor form to do this, since the authors of S4 objects are supposed to equip you with accessor functions that allow you to get anything that would be useful.

What does these R variable icons mean?

Are you using R Studio with R? If so, the following link should explain what the symbols mean. https://support.rstudio.com/hc/en-us/articles/205273297-Code-Completion. Broadly speaking, each symbol gives you an autocomplete option with the type of symbol representing the type of object you can autocomplete.

I believe the duplication of symbols for your ga.data frame is a bug with the current R Studio - it shouldn't make a difference which one you select, however.



Related Topics



Leave a reply



Submit