题目
STAT0004_25-26 Monday Dec 8th ICA - ALL GROUPS (12:10-12:50)
多项选择题
100 students take an exam and each gets an integer mark between 0 and 100, but 10 of the 100 students are absent on the day and receive a 0. The marks are stored in an R variable called marks and you are interested in calculating the average mark of the students that DID take the exam. Which of the following expressions can be used to compute this? For this question, you can assume that none of the students who attended the exam received a 0.
选项
A.a. mean(marks[marks > 0])
B.b. mean(marks[marks != 0])
C.c. mean(marks>0)
D.d. mean(marks[marks>=0])
E.e. sum(marks) / sum(marks > 0)
F.f. sum(marks[marks > 0]) / sum(marks > 0)

查看解析
标准答案
Please login to view
思路分析
Question restatement: There are 100 students, with 10 absent who receive 0. The vector marks contains these 0s for absentees and positive integers for attendees. We want the average mark of the students who DID take the exam. None of the attending students received a 0.
Option a: mean(marks[marks > 0]). This selects all marks strictly greater than 0 and computes their mean. Since only attendees have positive marks (absentees are 0), this is ......Login to view full explanation登录即可查看完整答案
我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。
类似问题
Suppose you created a vector as follows: mid_score <- c(20, 30, 10, 40). What would the following code return when executed properly? sum(which(mid_score > 20))
What is the average screen size of the iPhone models except the model with the largest screen size? mean(xxxx[which(screen_size xxx xxx(screen_size))]) Please complete the code. You can only use a vector name, function name, or logical comparison in each blank. mean([Fill in the blank] [which(screen_size [Fill in the blank] [Fill in the blank] (screen_size))])
except_the_first <- model[-1] The above code creates a vector (named except_the_first) consisted of model names except the first model name in the model vector (i.e., a vector consisting of values in all positions except the first position in model vector).
Let's start with creating the following vector. my_vector <- c(1,2,3,4,5,6,7,8,9,10) After creating the vector, if you execute the following code successfully in R, the output given is 4. [ Select ] sum mean median sd (my_vector >= 4 & my_vector < [ Select ] 5 6 7 8 9 10 ) Please complete the formula. You can only use a single-digit number, name of an aggregate statistics function (such as sum, mean, median, sd, etc.), a logical operator, or an arithmetic operator in each blank.
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!