Please download the file https://anaraven.bitbucket.io/eval/2018/cmb1/disu/answers.Rmd. Write your student number in the correct place at the beginning of the answer file. When you finish, send the answers.Rmd file to andres.aravena+cmb@istanbul.edu.tr. Be sure to use the correct email address and send only one file.

1 Lists and vectors

1.1 Write an R command to create the variable x with this content:

# write your answer here
$name
[1] "Ali"   "Bahar" "Cem"   "Deniz" "Elif"  "Faruk" "Güney" "Haluk" "Irem" 

$age
[1] 20 23 26 29 32 35 38 41 44

1.2 Write the code to print the third name

# write your answer here
[1] "Cem"

1.3 Write the code to print the median of age

# write your answer here
[1] 32

1.4 Write the code to find the name of the person with the median age

# write your answer here
[1] "Elif"

1.5 Write the code to create a vector v with the element ages in x. Assign the element names as names of the elements of v

# write your answer here
  Ali Bahar   Cem Deniz  Elif Faruk Güney Haluk  Irem 
   20    23    26    29    32    35    38    41    44 

1.6 Write the code to find in v the name of the person with the median age

# write your answer here
Elif 
  32 

2 Data frames, part A

2.1 Write an R command to create the variable df with this content:

# write your answer here
   name age
1   Ali  20
2 Bahar  23
3   Cem  26
4 Deniz  29
5  Elif  32
6 Faruk  35
7 Güney  38
8 Haluk  41
9  Irem  44

(you can write all the values again, or you can use as.data.frame)

2.2 Write the code to print the third name

# write your answer here
[1] Cem
Levels: Ali Bahar Cem Deniz Elif Faruk Güney Haluk Irem

2.3 Write the code to print the mean of age

# write your answer here
[1] 32

2.4 Write the code to find in df the name of the person with the median age

# write your answer here
[1] Elif
Levels: Ali Bahar Cem Deniz Elif Faruk Güney Haluk Irem

3 Data frames, part B

Your computer has already a ChickWeight data frame with four columns, from an experiment on the effect of diet on early growth of chicks.

3.1 Please write an R command to get the names of the columns of ChickWeight.

# write your answer here
[1] "weight" "Time"   "Chick"  "Diet"  

3.2 Please write an R command to get the number of rows of ChickWeight.

# write your answer here
[1] 578

3.3 Write an R command to get the values for the 43rd row of ChickWeight

# write your answer here
   weight Time Chick Diet
43    102   12     4    1

3.4 Write an R command to get the Chick number of the chickens with weight greater than 330. Chick numbers can be repeated.

# write your answer here
[1] 21 34 35 35 35
50 Levels: 18 < 16 < 15 < 13 < 9 < 20 < 10 < 8 < 17 < 19 < 4 < ... < 48