In this practice, we will cover concepts from the below topics
- R Tutorial 2: Working Environment
- R Tutorial 3: Basic Programming
- R Tutorial 4: Data Structure
- R Tutorial 5: Basic Programming – Continued
Exercise 1 – Using R as a calculator
In the console of R, perform the operations as below:
- Choose any number and add 2 to it
- Multiply the result by 3.
- Subtract 6 from answer.
- Divide what you get by 3.
You should get the same number.
Assignment requirement
No need to submit this exercise
Exercise 2 – Writing your first R script
Assign 2 to variable number “a” and 2 to variable number “b”. Add them up and minus 1 and do this all in the script!
Assignment requirement
Show the simple lines of code
Exercise 3 – AutoGrader
Try to code an if-else programme to allocate grades to a certain mark
A+ : 90
A: 80
B+: 75
B: 70
C: 60
D: 50
Assignment requirement
Your code should have the below format.
Grade <- 85 (We will change this accordingly to test the code)
-if else code comes here-
Exercise 4 – Create your dataframe
Shoe | Colour | Price |
Running Shoe | Blue | 59 |
High Heels | Red | 65 |
Assignment requirement
Put this information into an excel, import it into R, then add another column for stock units left, add another entry for another shoe type, before exporting out to another excel file. We will change the directory accordingly
– End of Assignment 1 –