What is the meaning of the dollar sign “$” in R function()?

The $ allows you extract elements by name from a named list. For example

x <- list(a=1, b=2, c=3)
x$b
# [1] 2

You can find the names of a list using names()

names(x)
# [1] "a" "b" "c"

This is a basic extraction operator. You can view the corresponding help page by typing ?Extract in R.

Leave a Comment

error code: 523