Page 1 of 1

code in R 4. Write the code corresponding to the following: if i and j have different values, assign result to be 5, oth

Posted: Tue Jul 12, 2022 8:05 am
by answerhappygod
code in R
4. Write the code corresponding to the following: if i and j have different values, assign result to be 5, otherwise assignresult to be 10. (Submit the code as your answer to this question. But test your code by trying a variety of values for i and j.) (1 point)
6. Write an R expression (no loops or assignments) that shows the median body weight of the male cats in the “cats” dataset. The load of the library that contains the “cats” dataset is provided. (2 points)
8. Imagine you are taking three classes in person this summer. Show the set of R commands that would create a vector of character strings that represent the locations of those classes. For example, the strings in your vector might be “Rauch 161,” “STEPS 101,” “Packard 466,” and “Whitaker 303.” Assign the class code that meets there (e.g., “DSCI310”) as the name for each position of the vector. (2 points)
Answer:
class_locations <- c("Rauch 161", "STEPS 101", "Packard 466", "Whitaker 303")names(class_locations) <- c("DSCI310", "DSCI311", "DSCI312", "DSCI313")class_locations
9. Show the expression using the vector you created in #8 that would display the meeting location for DSCI310, regardless of where DSCI310 is in your vector. Do not use a loop. (1 points)
10. Show the expression that produces the vector of class codes in your schedule from #8 EXCEPT for DSCI310. Do not use a loop. (2 points)
11. Using the provided vector below, provide code that would calculate and then print three comma-separated values from the vector: the minimum, the mean, and the maximum. E.g for the vector c(1, 2, 3, 4, 5) the result will output “1, 3, 5”. (2 points)
12. Write the expression for the entropy of a collection that has 9 positively labeled items and 13 negatively labeled items? (2 points)
13. Write the expression for the information gain of an attribute that takes a collection with 12 positive items and 52 negative items and divides it into three collections: the first having 10 positive and 20 negative items, the second having 2 positive and 10 negative items, and the third having just 22 negative items? (2 points)