LA2: R Basic Operations
Marking Key: 10 questions x 10 marks = 100 marks
1) Make a variable named Digit in R and assign to it the value – 6. Enter you work in the following box:
>
2) Now that you created the variable Digit, enter the command you will use to display in the R screen (console) what the value of the variable Digit would be:
>
3) Enter below the commands you will execute in the R console to make a numeric vector Scores that will contain numeric values 4, 8, – 6, 0, – 15 in it, in that order:
>
4) Enter below the commands you will execute in the R console to make a character vector Colors that will contain values blue, red, yellow, red, green in it, in that order:
>
5) Now that you created the vector Colors above, enter below the command you will execute to find the length of this vector:
>
6) How would R evaluate the following?
> (2+2 == 4) | (2+2 == 5)
[1]
7) What does the following code produces?
Be aware of the result: would that be integer, numeric, logic, character, etc…
>v <- c( 2,5.5,6)
>t <- c(8, 3, 4)
>print(v-t)
[1]
8) How would R evaluate the following?
> 3!=4
[1]
9) What does the following code produces? Round to two decimal places.
Be aware of the result: would that be integer, numeric, logic, character, etc…
>v <- c( 2,5.5,6)
>t <- c(8, 3, 4)
>print(v^t)
[1]
10) What does the following code produces?
Be aware of the result: would that be integer, numeric, logic, character, etc…
>v <- c(2,5.5,6,9)
>t <- c(8,2.5,14,9)
>print(v < t)
[1]