Please change 林木木 to your name, and 411073221 to your school id.
The exam has two part:
12 Questions. Each is worth 6 points. Please run the following command to visit the form for multiple choices.
browseURL("https://docs.google.com/forms/d/e/1FAIpQLSflXzhzA9ft-bVJNMgshQb-fl5M9_p0RGDo9BCLX2ZaBFWmIA/viewform?usp=sf_link")
One big question with 5 small questions. Each is worth 6 points.
Each question is framed like:
Create an object named practice and bind a numeric value of 5 to it.
# practice
All program lines must be inside a corresponding code chunk with code chunk label ansXX
, like the one ans0
above. (程式碼請寫在每小題如上帶有ansXX
標籤的code chunk裡)
Keep # practice
at the very last line inside your code chunk. You can remove # if you want, but it must be the last line. (code chunk的最後一行請保留為# xxx
,即原始code chunk所附帶的# xxx
)
To check whether your answer is correct, we will run the lines in that code chunk, then do a name call on the very-last-line object (i.e. practice here) (so you better do a name call in console on the very-last-line name to see if it delivers the answer value you want.) (# xxx
中的xxx是最後答案正確與否的依據,所以完成該小題你最好執行xxx的name call來檢查你的答案值。)
DO NOT touch the code chunk label (i.e. ans_practice here). Computer will fail to run your codes if you touch and change it.(code chunk一開頭的ans_xxx
為code chunk label, 請不要動到它,否則會造成考卷判讀錯誤。)
An online survey is distributed to students of Economics department.
There are two questions:
question 1: "Are you happy with our campus? Choose a number from 5(very happy), 4(happy), 3(satisfy), 2( unhappy), to 1(very unhappy)."
question 2: "Did you participate in any of the following activities? Check all that apply to you. (student association, school club, school sport team, department sport team)"
Suppose the following retrieval will print each question respectively:
survey$questions[[1]] # will show as "Are you happy with our campus? Choose a number from 5(very happy), 4(happy), 3(satisfy), 2( unhappy), to 1(very unhappy)." survey$options[[1]] # will show as c(1, 2, 3, 4, 5) survey$questions[[2]] # will show as "Did you participate in any of the following activities? Check all that apply to you. (student association, school club, school sport team, department sport team)" survey$options[[2]] # will show as c("student association", "school club", "school sport team", "department sport team")
Construct the survey
object that can satisfy the above retrieval outcomes:
# declare then add method survey <- list() # declare survey$questions[[1]] <- "Are you happy with our campus? Choose a number from 5(very happy), 4(happy), 3(satisfy), 2( unhappy), to 1(very unhappy)." # then-add survey$options[[1]] <- c(1, 2, 3, 4, 5) survey$questions[[2]] <- "Did you participate in any of the following activities? Check all that apply to you. (student association, school club, school sport team, department sport team)" survey$options[[2]] <- c("student association", "school club", "school sport team", "department sport team") # survey
One student's response is
question 1: 4
question 2: "school club" and "department sport team"
Construct an object named single_response
whose structure satisfies the following requirements:
choice1 <- single_response$questions[[1]] survey$options[[1]][[choice1]] # will show as 4 choice2 <- single_response$questions[[2]] survey$options[[2]][choice2] # will show as c("school club", "department sport team")
single_response <- list() # declare single_response$questions[[1]] <- 4 single_response$questions[[2]] <- c(2, 4) # single_response
There are three students responded to the survey. Their choices are
Store three responses in responses
object so that for i=1
i=1 survey$options[[1]][ responses[[i]]$questions[[1]] ] # show student i's chosen option from question 1 as 4 survey$options[[2]][ responses[[i]]$questions[[2]] ] # show student i's chosen options from question 2 as c("school club", "department sport team")
responses <- list( list( questions=list( c(4), c(2, 4) ) ), list( questions=list( c(3), c(NA) ) ), list( questions=list( c(5), c(1, 2, 3) ) ) ) # responses
Modify responses
so that:
student 2's response is removed completely
student 1 and 3's response to question 1 are all changed to 3
# version 2 responses[[1]]$questions[[1]] <- 3 responses[[3]]$questions[[1]] <- 3 responses[[2]] <- NULL # responses
responses
from the previous question is an observation-by-observation data set. We want to construct a feature-by-feature data set. The feature names are:
For question2.XXX features, their values are logical. TRUE means the student has participated in activity XXX; FALSE means has not. Please construct a feature-by-feature list data set for those three students based on their 1.3 answers, and save the data set to object responses_fbf
responses_fbf <- list( question1 = c(4, 3, 5), question2.student_association = c(F, NA, T), question2.school_club = c(T, NA, T), question2.school_sport_team = c(F, NA, T), question2.department_sport_team = c(T, NA, F) ) # responses_fbf
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.