The R programming is a Statistical analysis language developed by Ross Ihaka and Robert. It is a system for statistical computation and for graphics. The R language is also a dialect of the S language, which is developed in the late 1980s. But the most asked question on the web is about ‘$’ in R programming. In this article, I try my best to explain in an interactive and simpler way.

Being a statistical analytical language, it found many applications in data analytics. The features of the R language is briefly mentioned below for your reference.

'$' in R programming

Features of R language

  • R is a very good statistical language that is well developed and includes loops, functions, input, and outputs.
  • Very effective in data manipulation, analysis and storage capabilities.
  • Provides a bunch of operators for calculations on arrays, lists, and more.
  • It provides large integration of the analytical tools.
  • It provides the graphical facilities to view or print down the visualizations on paper.

What is ‘$’ in R programming

Most of the people like you, may be wondering about the ‘$’ in R programming. R programming has 4 types of extractors or extracts operators. [, [[, $ and @. 

The first one i.e. ‘[‘ operator is used to extracting content from the vectors, lists, or a data frame. And the second operator i.e. ‘[[‘ and ‘$’ is used to extract the content from the single object.

Without much confusion, let’s illustrate the the above to understand the use of ‘$’ in R programming.

For this let’s import a dataset, ‘BOD’.

datasets:BOD
  Time  demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8

This is the dataset of ‘BOD’. Here now we are going to Extract the Values present in the ‘Time’ column.

Here we can make use of ‘$’ in R programming to get those specific values out of the dataframe.

BOD$Time
1 2 3 4 5 7
BOD$demand
8.3 10.3 19.0 16.0 15.6 19.8

By now, I hope you got the better of ‘$’ sign in R. You can use to extract the particular values out of the input data.

Using ‘$’ in R programming – Vectors

Now, we are going to create a vector/list having some values in it. Later we can apply the ‘$’ extractor operator to get the specific values out of the list.

Let’s see how it works.

df<-list(A = 'Mark', B= 'Ross', C= 'Brown',D= 'Jessy')

This is the list that we created for this illustration. It has 4 members in it. Let’s see how we can extract each name using the ‘$’ in R.

df$A
"Mark"
df$B
"Ross"

Just like this, you can easily get the specific values out of a list, vector, or a data frame in R language.

Wrapping Up

R is a wonderful statistical analysis language that provides more value in Data analysis. The ‘$’ in R programming is an extract operator, using which you can easily extract the specific values out of a list, vector, or a data frame.

That’s all about ‘$’ in R. Happy Extracting!!!

More read: R documentation.

Categorized in: