【R语言】基础知识点 Pop quiz
前言
在这里会有10道题,每一道都是对R语言的基础了解。
有单选题和填空题,答案在最下面。
填空题可以放到Rstudio里运行得出答案。
Question 1
How would you select the data frame representing the reviews from the
list
?
您将如何从列表中选择代表评论的数据框?(单选题)
-
list[[reviews]]
-
list[["reviews']]
-
list$"reviews"
-
list["reviews"]
Question 2
Which symbol marks the beginning of a comment in R?
哪个符号标志着 R 中注释的开始?(单选题)
-
*
-
#
-
/*
-
%
Question 3
Complete the code to return the output.
完成代码以返回输出。(单选题)
vector1 <- 1:4
vector2 <- c("a","b","c","d")
vector3 <- c(TRUE, TRUE, TRUE, FALSE)
my_list <- 【 ? 】(vector1, vector2, vector3)
my_list
================================================
#output
[[1]]
[1] 1 2 3 4
[[2]]
[1] "a" "b" "c" "d"
[[3]]
[1] TRUE TRUE TRUE FALSE
-
data.frame
-
matrix
-
list
Question 4
Complete the code to return the output
完成代码以返回输出。(填空题)
df <- 【?】(
x = c("q" , "p"),
y = c(2 , 4)
)
str(df)
================================================
#output
'data.frame': 2 obs. of 2 variables:
$ x: chr "q" "p"
$ y: num 2 4
Question 5
Complete the code to return the output
完成代码以返回输出。(填空题)
vector <- c("a" , "b" , "c" , "d")
my_list <- list(vec 【?】 vector)
my_list
================================================
#output
$vec
[1] "a" "b" "c" "d"
Question 6
Which one of these is a
boolean
vector in R?
其中哪一个是 R 中的布尔
向量? (选择题)
-
(TRUE ,FALSE, FALSE)
-
c(True ,False, False)
-
c(TRUE ,FALSE, FALSE)
-
[True ,False, False]
Question 7
Complete the code to return the output
完成代码以返回输出。(选择题)
character_vector <- 【?】("python" , "SQL" , "R")
-
f
-
v
-
c
Question 8
Complete the code to return the output
完成代码以返回输出。(填空题)
speed_vector <- c("medium" , "slow" , "fast")
factor_sp_vec <- factor(speed_vector , ordered = TRUE , 【?】 = c("slow" , "medium" , "fast"))
factor_sp_vec
================================================
#output
[1] medium slow fast
Levels: slow < medium < fast
Question 9
Complete the code to return the output
完成代码以返回输出。(单选题)
name <- c("Python", "R", "SQL")
type <- c("Practice", "Project", "Lecture")
number <- c(100, 430, 200)
courses_df <- data.frame(name, type, number)
【?】(courses_df, number < 300)
================================================
#output
name<chr> type<chr> number <dbl>
1 Python Practice 100
3 SQL Lecture 200
-
subset
-
c
-
facter
-
apply
Question 10
Which function is used to give names to components of a list?
哪个函数用于为列表的组件命名?(单选题)
-
vector()
-
list()
-
names()
答案
Q1: list[["reviews']]
Q2: #
Q3: list
Q4: data.frame
Q5: =
Q6: c(TRUE ,FALSE, FALSE)
Q7: c
Q8: levels
Q9: subsety
Q10: names()