Tilde Symbol (~) in R

The tilde symbol (~) usually means approximately. In some programming languages like C, Java, and JavaScript, it represents an operator. In the R language, it is used for separating the right and left operands in a formula.

R is very highly used for statistical and data analysis. It contains the use of many formulas for different purposes. That is why the tilde symbol (~) is used very frequently in R.

The dependent variable is taken on the left of the ~ symbol, and the right side consists of explanatory variables. A sample formula that will demonstrate the use of the ~ symbol is shown below:

s <- lhs ~ rhs
lhs ~ rhs

In the example, s is a sample formula. Notice the use of the tilde symbol (~) in the formula.

In R programming, we can use the help() function to find information about any function, operator, or any other object. We can also use it to find out more about the tilde symbol (~). The code below shows how:


It returns the documentation of the ~ symbol in the file browser tab in R-Studio.