Intermediate R

Find the solution to these exercises without using R.

Exercise 1: Write the output.

TRUE & FALSE | TRUE | FALSE
Answer

TRUE

Exercise 2: Write the output.

TRUE & FALSE | TRUE & FALSE
Answer

FALSE

Exercise 3: Write the output.

TRUE | FALSE & TRUE & FALSE
Answer

TRUE

Exercise 4: Write the output.

num <- c("GER", "ESP", "ITA", "GER", "FRA", "BUL")
sum(num == "GER")
Answer

2

Exercise 5: Write the output.

num <- c("GER", "ESP", "ITA", "GER", "FRA", "BUL")
mean(num == "GER")
Answer

0.3333333

Exercise 6: Write the output.

count <- c(10, 4, 2, 6)
sum(count > 5)
Answer

2

Exercise 7: Write the output.

perc <- c(10, 4, 2, 6)
mean(perc > 5)
Answer

0.5

Exercise 8: Write the output.

factor(c(1, 3, 1, 4), labels = c("B", "A", "C"))
Answer

B A B C

Previous