Data Engineering and Mining I Name: Paul Brown

AI4OPT - Summer 2022 Due Date: June 22 2022

1. Interpret the following statement:

rnorm(6, mean = 8, sd = 1.5)

Six observations with a mean of 8 and a standard deviation of 1.5

2. Let n = 10. Write the code to yield the result of the

standard error (se) = sqrt(s2/n).

se <- function(x) sqrt(var(x) / length(x))

#3. convMeters(83.4, “feet”) # function is convMeters and 83.4 and “feet are the argument

#4. Use the recycling method to find v1+ v2:

    v1 <- c(2, 5, 3 ,8 , 6)
    v2 <- c(9, 7, 1)
    v1 + v2

#5. 4. Factors provide an easy and compact form of handling what kind of data? ________

Categorical

#6.
x <- factor( c(‘adult’, ‘adult’, ‘height’, ‘weight’, ‘adult’, weight’, weight’, ‘height’)

    x
    table(x)        

#7. Generate a sequence using the following: rep(12, 6). rep(12,6)

#8. Generate a sequence using the following: gl(3,4) gl(3,4)

#9. In the following statement, what do you call the objects, 2, 4, byrow = TRUE?

2 represents the number of rows and 4 the number of columns

Byrow = TRUE will fill in the table by using values for rows

first then followed by columns

#10.
results <- matrix(c(10, 30, 50, 43, 56, 21, 30), 2, 4, byrow = TRUE)

#11 Given the vector, a <- c(-8, -3, 0, 5, 10 21, 30), list the results of the following:

    a <- c(-8, -3, 0, 5, 10, 21, 30)
    
    a[-3]
    
    a[ - (1:4)]
                

12. Given the vector, g <- c(67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), give the results of the following:

    g <- c(67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49)
    g <- matrix(c( 67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), 3, 4)
    g
    
    g <- matrix(c( 67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), 3, 4, byrow = TRUE)
    g
    
    g[ 2,  , drop = FALSE]
    g[  , 3,  drop = FALSE]
    g

13. 11. Let g1 <- matrix(c( 67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), 3, 4). Show the results of the following:

             g1 <-  matrix(c( 67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), 3, 4)
             cbind(c(22, 34, 43) , g1[  ,3] )
             
             results  <-  matrix(c(67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), 3, 4, byrow = TRUE)                 
             colnames(results)  <-  c(“1st”. “2nd”, “3rd”, “4th”)
             rownames(results) <-  c(“car1”, “car2”, “car3”)   
             results
             
             k  <- array(1:12,  dim = c(2, 3, 2))
             k