Hello guys, what’s up? I have found that many of you are searching about $ symbol in r. It’s quite easy. Let’s start—
In R programming language, there are 4 forms of the extract operator. Those are [, [[, $, and @.
[, can be used to extract content from vectors, lists, or data frames.
$, extract content from a single object.
Here I am not discussing about the entire operator. I just clarify you what is $ symbol in r with proper example.
As earlier what I have told, $ is used to extract content from a single object. Then means it is used to refer to an element in a list or a column in a data frame.
We often want to select an entire column, namely one specific variable from a data frame. If we want to select all elements of the variable diameter, we can just write this—
Or you can write like below—
Then it returns all of the values in the column labeled john. Assuming that the numbers are the actual column numbers, we can get the same result by calling:
It returns all values in column index position ‘1’.
Mylist = list (x=1, y=42) Mylist$y
After execution of it, it will print 42
x <- list(a=1, b=2, c=3) x$b #  2
So, guys, that’s all about $ symbol in r. Later we will discuss another topic of r programming language. Till then, take care. Happy Coding