Data Engineering and Mining I Name: Paul Brown
AI4OPT - Summer 2022 Due Date: June 23, 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. In the following code, what is the function and what is the
argument(s):
convMeters(83.4, “feet”)
ConvMeters is the function and the argument is how many feet in 83.4
meters
4. Use the recycling method to find v1+ v2:
v1 <- c(2, 5, 3 ,8 , 6)
v2 <- c(9, 7, 1)
v1 + v2
5. Factors provide an easy and compact form of handling what kind of
data? ________
Categorical
6. Given x <- factor( c(‘adult’, ‘adult’, ‘height’, ‘weight’,
‘adult’, weight’, weight’, ‘height’)
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)
Generate a sequence using the following: gl(3,4)
gl(3,4)
8. 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
results <- matrix(c(10, 30, 50, 43, 56, 21, 30), 2, 4, byrow =
TRUE)
Get a message indicating that length 7 is not a sub-multiple
results <- matrix(c(10, 30, 50, 43, 56, 21, 30), 2, 4, byrow = TRUE)
9. 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[a <= 0 | a > 10]
a[c(3, 6)]
#10. 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)]
11. 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)
install.packages(“rmarkdown”)