【R语言2】Introduction to R 基础知识复习小测试 Pop quiz


前言

在这里会有10道题,每一道都是对R语言的基础了解。
有单选题和填空题,答案在最下面。
填空题可以放到Rstudio里运行得出答案。


Question 1

Which one of these is a logical value in R?
其中哪一个是 R 中的逻辑值?(单选题)

  • TRUE
  • True
  • true

Question 2

What does 2:4 do?
程序中2:4是干什么的?(单选题)

  • generates a vector with all integer values from 2 up to 4
  • generates a function with all integer values from 2 up to 4
  • generates a vector with all integer values from 2 up to 3

Question 3

Complete the code to return the output
完成代码以返回输出(填空题)

my_list <- list(5:6, c("A", "B"), 10:12)
【这里输入code】<- c("p", "q", "r")
my_list

=======输出========
$p
[1] 5 6

$q
[1] "A" "B"

$r
[1] 10 11 12

Question 4

Complete the code to return the output
完成代码以返回输出(单选题)

num_matrix <- matrix(1:9, byrow = TRUE, nrow = 3)
big_matrix <-【这里选择code】(num_matrix, rowSums(num_matrix))
big_matrix

=======输出==========
    [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9
[4,]    6   15   24
  • cbind
  • rbind
  • matrix

Question 5

Complete the code to return the output
完成代码以返回输出(单选题)

a <- c(1, 2, 3) 
b <- c(4, 5, 6)
c <- a 【这里选择code】b
c

========输出=========
[1] 5 7 9
  • ++
  • +
  • *

Question 6

what is an ordered factor vector helpful for?
什么是有序因子向量有助于?(单选题)

  • Ordered factors have equal values attached to theme
  • It enables us to compare different elements
  • R throws a warning message when comparison is made.

Question 7

Which of the following selects the first element of the vector y?
以下哪个选择了向量y的第一个元素(单选题)

  • y[1]
  • y[1 , 1]
  • y[0]
  • y[“1”]

Question 8

When selecting items from a matrix, what is used to separate the rows you want to select from the columns?
从矩阵中选择项目时,用什么将要选择的行与列分开?(单选题)

  • ,
  • .
  • :

Question 9

Select those element of a vector a that have the names Monday and Tuesday
选择向量“a”中名称为“Monday”和“Tuesday”的元素

  • a[c(Monday , Tuesday)]
  • a["Monday , “Tuesday”]
  • a[c(“Monday” , “Tuesday”)]

Question 10

Complete the code to return the output
完成代码以返回输出(填空题)

x <- c(1 , 1 , 1)
# 将 x 中的所有元素相加
【选择下列code】(x)
  • add
  • mean
  • sum
  • total

是兄弟就砍一刀!

温故而知新

答案

Q1:TRUE

Q2:generates a vector with all integer values from 2 up to 4

Q3:names(my_list)

Q4:rbind

Q5:+

Q6:It enables us to compare different elements

Q7:y[1]

Q8:,

Q9:a[c("Monday" , "Tuesday")]

Q10:sum

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值