[For this exercise, first write down your answer, without using R. Then, check your answer using R.]

Answers to the exercises are available here.

**Exercise 1**

Consider two vectors, `x, y`

`x=c(4,6,5,7,10,9,4,15)`

`y=c(0,10,1,8,2,3,4,1)`

What is the value of: `x*y`

**Exercise 2**

Consider two vectors, `a, b`

`a=c(1,2,4,5,6)`

`b=c(3,2,4,1,9)`

What is the value of: `cbind(a,b)`

**Exercise 3**

Consider two vectors, `a, b`

`a=c(1,5,4,3,6)`

`b=c(3,5,2,1,9)`

What is the value of: `a<=b`

**Exercise 4**

Consider two vectors, `a, b`

`a=c(10,2,4,15)`

`b=c(3,12,4,11)`

What is the value of: `rbind(a,b)`

**Exercise 5**

If `x=c(1:12)`

What is the value of: `dim(x)`

What is the value of: `length(x)`

**Exercise 6**

If `a=c(12:5)`

What is the value of: `is.numeric(a)`

**Exercise 7**

Consider two vectors, `x, y`

`x=c(12:4)`

`y=c(0,1,2,0,1,2,0,1,2)`

What is the value of: `which(!is.finite(x/y))`

**Exercise 8**

Consider two vectors, `x, y`

` x=letters[1:10]`

`y=letters[15:24]`

What is the value of: `x<y`

**Exercise 9**

If `x=c('blue','red','green','yellow')`

What is the value of: `is.character(x)`

**Exercise 10**

If `x=c('blue',10,'green',20)`

What is the value of: `is.character(x)`

**Want to practice vectors a bit more? We have more exercise sets on this topic here.**

Yesim says

I think that it would be nicer if you can add some information. For instance, In Exercise 10, why numbers such as 10 is counted as “character”? I am a beginner and I would need explanations as such.

Christian says

Hi,

I completely agree with you!

In this case it should be due to R’s inbuilt type conversion: https://www.r-bloggers.com/type-conversion-and-you-or-and-r/

//Chris

Al says

Great stuff! I would agree with Yesim. I would add more explanation in answer section (something like explanation for Dummies):)

For example exercise 7, what those numbers (answer) 1, 4 and 7 represents?

GOD says

maybe you already know the answer but i’ll post it anyway.

basically, x and y are divided and which ever value is not finite like 12/0,

that value’s position is the output.

so in this case 1, 4, 7.