What ~ (tilde) command do?

0 votes

I saw in a tutorial about regression modeling the following command :

myFormula <- Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width

What exactly does this command do, and what is the role of ~ (tilde) in the command?

Oct 30, 2018 in Data Analytics by Ali
• 10,400 points
119 views

1 answer to this question.

0 votes

Something that characterizes formulas in R is the tilde operator ~. With this operator, you can actually say: "capture the meaning of this code, without evaluating it right away”. That also explains why you can think of a formula in R as a "quoting" operator.

But what does a formula exactly look like? Take a closer look at the following line of code:

# A formula
c <- y ~ x
d <- y ~ x + b
# Double check the class of `c`
class(c)

'formula'

The variable on the left-hand side of a tilde (~) is called the "dependent variable", while the variables on the right-hand side are called the "independent variables" and are joined by plus signs +.

answered Oct 30, 2018 by Maverick
• 10,040 points

Related Questions In Data Analytics

0 votes
1 answer

How do I find out what directory R has chosen to store packages?

.libPaths() // You can use this command ...READ MORE

answered Apr 23, 2018 in Data Analytics by zombie
• 3,690 points
21 views
0 votes
1 answer

What do you understand by statistical power of sensitivity and how do you calculate it?

Sensitivity is commonly used to validate the ...READ MORE

answered Aug 20, 2018 in Data Analytics by Anmol
• 3,620 points
47 views
0 votes
1 answer

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

Structured query language (SQL) is a programming ...READ MORE

answered Aug 24, 2018 in Data Analytics by Anmol
• 3,620 points
95 views
0 votes
1 answer

What does the sink function do in R?

sink diverts R output to a connection ...READ MORE

answered May 24 in Data Analytics by Chandu
32 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
92 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
108 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,700 points
75 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
67 views
0 votes
1 answer

What do you mean by technically correct data in data science?

we define technically correct data as a ...READ MORE

answered Nov 14, 2018 in Data Analytics by Maverick
• 10,040 points
40 views
0 votes
1 answer

What are R packages

These are a few R packages available: tidyverse Shiny rmar ...READ MORE

answered Oct 26, 2018 in Data Analytics by Maverick
• 10,040 points
23 views