Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

DS 413/613 Midterm

1) Using the if-else coding structure demonstrated in class, write a function that will determine if a number is divisible by 3 and 4  If your number is divisible by 3 and 4, the function generates the following statement: this number is divisible by both 3 and 4. If the function is not divisible by both 3 and 4, the function produces a statement that reads: this number is not divisible by both 3 and 4. Test your function by using the numbers 744 and 159.

 2) Using r coding methods demonstrated in class, write a function that will produce the difference between the cubes and the squares of the first 5 positive integers. Your output should be given in reverse order. The following number sequence should be produced: 900 648 448 294 180.

3) U <- c(“Maine” , “Texas”, “Delaware”, “Oregon”, “Utah”, “Vermont”, “Ohio”)

a. Is U an atomic vector or a list ?

b. Using R coding, show two methods for extracting/subsetting the element Utah.

c. Use and show R code that will extract all elements except Ohio.

4)V = list(“Chicago”, k = list( 2, 6, 18, 24, 36), FALSE, 13, 1.3, z = 1:20)

a. Is V an atomic vector or a list ?  Justify your answer.

b. Use and show R code that will extract the 2nd element of V.

c. Use and show R code that classifies the element FALSE as logical.

5.Copy, paste and run the tribble given below.

tribble( ~John, ~Raymond, ~Martha, ~Alice, ~Juan,

86, 77, 81, 88, 90,

79, 78, 85, 81, 78,

76, 75, 88, 94, 81,

84, 90, 71, 84, 89,

100, 80, 93, 85, 84,

90, 73, 70, 88, 93

) -> TestScores

TestScores

a. Use and show R code (a map function) to find the mean for each column.

b. Use and show R code (a map function) to find the cube of each column element.

c. Use and show R code (a map function) to convert each column value to 100.

6. Use and show R coding that will produce the matrix given below.

     [,1] [,2] [,3] [,4]

[1,]    1    4    9   16

[2,]    4   16   36   64

[3,]    9   36   81  144

[4,]   16   64  144  256

7.  Use two or three sentences to explain each git command. (Do not run code; you will have that opportunity on the final exam)

a) git clone

b) git init

c) ls

d) git add

e) touch

f) git push -u

g) git commit -m

h) git branch

i) git merge