Day 7: Show that 1+1 = 3
We learned a lot in 6 days,
This includes how to:
install packages
load packages
view data
plot the data
draw the line of best fit
Good job on doing so! Visualisations are quite basic, but fun at the same time.
We don't stop here though... nope. We use this momentum to keep going 😎
No, we're not doing something fancy. We're going to the basics:
Addition
Subtraction
Multiplication
Division
In your R console, if you simply type 1+1, you should get the output 2(after hitting enter of course).
Now...
Let's do something different.
In my opinion, 1+1 equals three
Hear me out (and I'll show it to you)
1+1 = 2 right? (that's what we learned in school)
But... you can save it as 'three' in R 🤪
How?
Simple.
Three <- 1+1
When you run this code, you attribute 1+1 to 'three'
To attribute a line of code to a word you can do so using the <- operator.
This is known as 'assignment'
The word 'three' in this case becomes the 'object'.
You can find these objects in the 'environment' window.
You can perform other arithmetic functions as well
Here're some to try out:
6*9
Three * 2
(This will equal 4 because Three = 2)
3/4
There are several things to try so I'll leave it to you to play around.
That's it for today - assignments and basic arithmetic
Tomorrow we'll go into something a little more intense - Data Transformation