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.
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!
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
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
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 –