【R语言1】Introduction to 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()

你们对了多少个呢?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值