## 2.10 End of Chapter Exercise

### Data Conversion

1. Convert the following character string to numeric:

1. 1,234,567 (comma as decimal mark)
2. 1.234.566 (full stop as decimal mark)
2. Convert the following character string to date:

1. Jan-21-2004
2. 01-21-2004
3. Jaunary-21-04

### Vector

1. Create a vector of integers from 5 to 99.

2. Create a vector of five zeros.

3. Create a vectors of dates from January 1st, 2014 to January 5th, 2014.

### Factor

Using a numeric vector x = c(1,2,3,3,5,5,6,7,8,9,9,10):

1. create a factor vector that divides the data into three groups of the same lenght: High, Middle, and Low. (Hint: Use the function cut)

2. create a factor vector that divides the data into three groups: Above average, between average and lower quartile, and below lower quartile. (Hint: Use the function cut and quartile)

### Vector

1. Create two new numeric vectors x and y.
2. Create a new vector $$z = x + y$$.

### Matrix

1. Create two new numeric vectors x and y.
2. Create a dataframe from two newly created vectors.
3. Create a new column in the dataframe that $$w = x - 2 \times y$$.

### Function

1. Write the following function:
• take three numerical numbers,
• calculate the product of three numerical inputs,
• display the value, and
• return the value as function output.
2. Write the following function:
• take three numerical numbers, but the last input has default value of 1,
• calculate the sum of the first two numerical inputs, and then the result is multipled by the third input,
• display the value, and
• return the value as function output.

### Packages

1. Install package quantmod.