Конвертер валютUSD 2,9921EUR 3,3424Моя статистикаПройдите любой тест
Все записи блога →
Последние Новости
  • Тур Хейердал — путешественник, переплывший океан на плоту
    Шесть мужчин, бальсовый плот и бескрайний Тихий океан. Тур Хейердал хотел проверить смелую идею: могли ли жители Южной Америки в древности добраться до островов Полинезии. Чтобы узнать это, он сам отправился в путь.Путь к успехуТур Хейердал родился 6 октября 1914 года в городе Ларвик в Норвегии. С детства он увлекался зоологией и дикой природой. В 1937–1938 годах Тур с женой прожил около года на острове Фату-Хива в Полинезии. Именно там, наблюдая за ветрами и течениями, он задумался о происхожде...
  • Христофор Колумб — мореплаватель, открывший Европе Америку
    Утром 12 октября 1492 года матрос с корабля «Пинта» крикнул, что видит берег. Через несколько часов три небольших судна подошли к острову, который местные жители называли Гуанахани. Экспедиция Христофора Колумба завершила первый переход через Атлантический океан, после которого мир перестал быть прежним.Путь к экспедицииКолумб родился около 1451 года в Генуе в семье ткача. Он рано ушёл в море, плавал по Средиземному и Атлантическому океанам, жил в Португалии. Он был уверен, что до Индии и Китая ...
  • Фрэнк Синатра — «Голос» века, певший по-своему
    Шляпа с лентой, небрежно накинутый плащ, бархатный баритон — Фрэнк Синатра умел превратить трёхминутную песню в маленький спектакль. Прозвище «Голос» закрепилось за ним ещё в 1940-х, и за десятилетия его мало кто смог оспорить.Путь к успехуСинатра родился в декабре 1915 года в Хобокене, штат Нью-Джерси, в семье итальянских эмигрантов. Музыкального образования он почти не получил, зато с юности пел на радио и в клубах. Первые успехи пришли в оркестрах Гарри Джеймса и Томми Дорси. В начале 194...
  • Михаил Булгаков — мастер, которого прочли после смерти
    Автор, которого при жизни почти не печатали, оказался одним из самых читаемых писателей столетия. История Михаила Афанасьевича Булгакова — это история терпения, упорства и веры в свою книгу.Путь к успехуБулгаков родился в 1891 году в Киеве, в семье преподавателя духовной академии. В 1916 году он окончил медицинский факультет Киевского университета и сразу начал работать врачом, в том числе в земской больнице в селе Никольском Смоленской губернии. Эти годы позже отразились в «Записках юного врача...
  • Дмитрий Менделеев — химик, составивший карту всех элементов
    Дмитрий Иванович Менделеев родился 8 февраля 1834 года (27 января по старому стилю) в Тобольске, в большой семье директора гимназии. Рос он в трудное время, но мать, по семейным преданиям, сделала всё, чтобы младший сын получил образование. Так будущий учёный оказался в Петербурге.Путь к успехуОкончив Главный педагогический институт, Менделеев стажировался в Европе, а в 1860-х годах стал профессором Петербургского университета. Читая курс неорганической химии, он не нашёл подходящего учебника и ...
  • Роальд Амундсен — покоритель полюсов и северо-западного прохода
    Полярные льды веками хранили свои тайны. Роальд Амундсен разгадал сразу несколько из них. Он не искал лёгкой славы: каждый его поход был итогом долгой учёбы у местных народов и внимательного расчёта.Путь к успехуАмундсен родился 16 июля 1872 года недалеко от города Борге в Норвегии. Он собирался стать врачом, но, прочитав о полярных экспедициях, выбрал другую жизнь. В 1897–1899 годах он участвовал в бельгийской экспедиции на судне «Бельжика», которая стала первой, перезимовавшей в Антарктике. Та...
  • Франциск Скорина — первопечатник Беларуси и Восточной Европы
    В 1517 году в Праге вышла небольшая книга, которую можно держать в одной руке. Это была Псалтирь, а на её страницах стояло имя издателя: «Франциск Скорина из Полоцка, в лекарских науках доктор». Так началась история восточнославянского книгопечатания.Путь к книгеТочная дата рождения Скорины неизвестна, обычно называют около 1490 года. Он родился в Полоцке в семье купца. В 1504 году его имя записано среди студентов Краковского университета. В 1512 году в итальянской Падуе он получил степень докто...
  • Марк Шагал — художник, чьи герои парят над городом
    На картинах Марка Шагала люди летают над крышами, скрипач сидит на домике, а синяя корова смотрит на зрителя человеческими глазами. Это не просто фантазия: художник всю жизнь рисовал родной Витебск, каким его хранила память, — с поэтической логикой сна.Путь к успехуМарк Шагал (при рождении Мовша Шагал) родился в 1887 году в семье бедного еврейского рабочего недалеко от Витебска и вырос в самом Витебске. Он учился у местного художника Юделя Пэна, затем уехал в Санкт-Петербург. В 191...
  • Янка Купала — народный поэт Беларуси
    Когда в начале XX века молодой поэт из деревни под Минском подписал свои стихи псевдонимом «Янка Купала», он, возможно, и не думал, что станет голосом целого народа. Но именно так и произошло.Путь к успехуИван Доминикович Луцевич родился в 1882 году в фольварке Вязынка близ Молодечно. Семья была небогатой: родители арендовали землю. Учился он в народном училище, потом работал домашним учителем, писарем, помощником провизора, много читал и рано начал писать стихи. Первое стихотворение «Мужик» нап...
  • Луи Пастер — учёный, победивший невидимых врагов
    Луи Пастер родился 27 декабря 1822 года в городке Доль на востоке Франции, в семье кожевника. Он был прилежным, но не блестящим учеником и интересовался живописью. Однако судьбу решила химия: она повела его от кристаллов к микробам и спасению жизней.Путь к успехуПервое крупное открытие Пастер сделал в 1848 году, изучая кристаллы солей винной кислоты. Он заметил, что они бывают двух зеркально отражённых форм, и тем самым заложил основы стереохимии. Позже он занялся брожением и показал, что за нег...
МатематикаМоя статистика

Тест по языку R

100 вопросов в 11 темах (лёгкий — 35, средний — 40, сложный — 25). Выберите темы, уровень и количество вопросов — к каждому ответу есть объяснение.

Векторы и recycling, типы и NA, индексация, списки и data frame, функции, apply, строки, распределения, модели lm/glm, tidyverse и типичные ловушки. Вопросы на английском.

Все вопросы теста 100

Нажмите на вариант ответа, чтобы проверить себя, или «Показать ответ».

Vectors and recycling9
1Лёгкий
What does this code print?
x <- c(1, 2, 3)
x * 2
  1. [1] 1 2 3 1 2 3
  2. [1] 12
  3. Error: non-conformable arguments
  4. [1] 2 4 6
2Лёгкий
What does this code print?
x <- 1:10
sum(x > 5)
  1. [1] 40
  2. [1] 6
  3. Error: cannot sum a logical vector
  4. [1] 5
3Средний
What happens when this code runs?
c(1, 2, 3) + c(10, 20)
  1. It stops with an error because the lengths 3 and 2 differ
  2. It prints [1] 11 22 3 with no warning
  3. It prints [1] 11 22 13 with a warning that the longer length is not a multiple of the shorter one
  4. It prints [1] 11 22 with no warning
4Средний
What does this code print?
x <- 1:6
x[c(TRUE, FALSE)]
  1. [1] 1
  2. [1] 1 3 5
  3. [1] 2 4 6
  4. [1] 1 2
5Сложный
What is the first row of the result?
m <- matrix(1:6, nrow = 2)
m + c(10, 20)
  1. 11 23 15
  2. 11 12 13
  3. Error: non-conformable arrays
  4. 11 13 15
6Лёгкий
What does this code print?
c(1, 2, 3, 4) + c(10, 20)
  1. [1] 11 22 3 4
  2. [1] 11 22 13 24 and a warning about lengths
  3. [1] 11 22 13 24
  4. Error: vectors must have the same length
7Лёгкий
What does this code print?
seq(2, 11, by = 3)
  1. [1] 2 5 8
  2. [1] 2 5 8 11
  3. [1] 2 5 8 11 14
  4. [1] 2 3 4 5 6 7 8 9 10 11
8Средний
What is the result of this code?
x <- 1:5
x[8] <- 8L
x
  1. The vector grows to length 8; positions 6 and 7 become NA
  2. Error: subscript out of bounds
  3. The vector grows to length 8; positions 6 and 7 become 0
  4. x stays 1 2 3 4 5 and a warning is issued
9Средний
What does this code print?
x <- c(5, 2, 9, 1)
order(x)
  1. [1] 4 2 1 3
  2. [1] 1 2 5 9
  3. [1] 3 2 4 1
  4. [1] 3 1 2 4
Data types and coercion9
10Лёгкий
What does this code print?
typeof(5)
  1. [1] "integer"
  2. [1] "numeric"
  3. [1] "number"
  4. [1] "double"
11Средний
What does this code print?
c(length(NULL), length(NA))
  1. [1] 0 0
  2. [1] 1 1
  3. [1] 0 1
  4. [1] NA NA
12Средний
What does this code print?
f <- factor(c("low", "high", "medium", "low"))
levels(f)
  1. [1] "low" "high" "medium"
  2. [1] "low" "medium" "high"
  3. [1] "low" "high" "medium" "low"
  4. [1] "high" "low" "medium"
13Сложный
What does this code print?
c(NA & FALSE, NA | TRUE, NA & TRUE)
  1. [1] NA NA NA
  2. [1] FALSE TRUE TRUE
  3. [1] FALSE FALSE NA
  4. [1] FALSE TRUE NA
14Лёгкий
What does this code print?
class(c(1, "a", TRUE))
  1. [1] "numeric"
  2. [1] "logical"
  3. [1] "character"
  4. [1] "list"
15Лёгкий
What is the result of as.numeric("abc")?
  1. An error: cannot coerce "abc" to numeric
  2. NA, with the warning "NAs introduced by coercion"
  3. 0
  4. NaN
16Средний
What does this code print?
c(is.na(NaN), is.nan(NA))
  1. [1] FALSE FALSE
  2. [1] TRUE TRUE
  3. [1] FALSE TRUE
  4. [1] TRUE FALSE
17Средний
What does this code print?
x <- c(1, NA, 3)
x == NA
  1. [1] FALSE TRUE FALSE
  2. [1] FALSE FALSE FALSE
  3. [1] NA NA NA
  4. Error: comparison with NA is not allowed
18Сложный
What does this code print?
as.logical(c("yes", "TRUE", "T", "0"))
  1. [1] TRUE TRUE TRUE FALSE
  2. [1] NA TRUE NA FALSE
  3. [1] NA TRUE NA NA
  4. [1] NA TRUE TRUE NA
Indexing and subsetting9
19Лёгкий
What does this code print?
x <- c(10, 20, 30, 40)
x[-2]
  1. [1] 30
  2. [1] 10 20 30
  3. [1] 10 30 40
  4. [1] 40
20Средний
What does this code print?
x <- c("a", "b", "c")
x[0]
  1. [1] "a"
  2. [1] NA
  3. character(0)
  4. Error: index 0 is out of range
21Средний
What does this code print?
df <- data.frame(x = 1:3, y = c("a", "b", "c"))
df[df$x > 1, "y"]
  1. [1] "b" "c"
  2. [1] "a"
  3. [1] 2 3
  4. [1] "a" "b" "c"
22Сложный
What does this code return?
m <- matrix(1:6, nrow = 2)
dim(m[1, ])
  1. [1] 1 3
  2. [1] 3 1
  3. NULL
  4. [1] 3
23Сложный
What does this code print?
l <- list(value = 5)
c(is.null(l$val), is.null(l[["val"]]))
  1. [1] FALSE TRUE
  2. [1] TRUE TRUE
  3. [1] FALSE FALSE
  4. [1] TRUE FALSE
24Лёгкий
What does this code print?
x <- c(a = 1, b = 2, c = 3)
x[c("c", "a")]
  1. The values 1 and 3, labelled a and c (original order)
  2. The values 3 and 1 without names
  3. The values 3 and 1, labelled c and a (in that order)
  4. Error: character subscripts are not allowed
25Средний
What does this code print?
l <- list(a = 1, b = "x")
c(class(l["a"]), class(l[["a"]]))
  1. [1] "numeric" "numeric"
  2. [1] "list" "list"
  3. [1] "list" "numeric"
  4. [1] "numeric" "list"
26Средний
What happens here?
x <- 1:5
x[c(-1, 2)]
  1. [1] 2
  2. An error: only 0 may be mixed with negative subscripts
  3. [1] 2 3 4 5 2
  4. [1] 2 3 4 5
27Сложный
What does this code print?
x <- c(1, NA, 3)
x[x > 1]
  1. [1] 3
  2. [1] NA 3
  3. [1] 1 3
  4. Error: missing value where TRUE/FALSE needed
Lists and data frames9
28Лёгкий
What does this code print?
l <- list(a = 1, b = 2, c = 3)
l$b <- NULL
names(l)
  1. [1] "a" "b" "c"
  2. NULL
  3. [1] "a" "c" "b"
  4. [1] "a" "c"
29Средний
What does this code print?
x <- unlist(list(a = 1, b = list(c = 2, d = 3)))
names(x)
  1. [1] "a" "c" "d"
  2. [1] "a" "b.c" "b.d"
  3. [1] "a" "b"
  4. NULL
30Средний
In R 4.0 or later, what does this code print?
df <- data.frame(g = c("a", "b"))
class(df$g)
  1. [1] "character"
  2. [1] "factor"
  3. [1] "list"
  4. [1] "data.frame"
31Сложный
What does this code print?
l <- list(a = 1, b = 2)
l["b"] <- list(NULL)
length(l)
  1. [1] 2
  2. [1] 1
  3. [1] 0
  4. Error: replacement has length zero
32Лёгкий
What does this code print?
df <- data.frame(a = 1:3, b = c("x", "y", "z"))
dim(df)
  1. [1] 2 3
  2. [1] 6
  3. [1] 3
  4. [1] 3 2
33Средний
What does this code print?
df <- data.frame(x = 1:5, y = 6:10, z = 11:15)
length(df)
  1. [1] 5
  2. [1] 15
  3. [1] 3
  4. [1] 1
34Средний
What happens when this code runs?
df <- data.frame(x = 1:3, y = 1:2)
  1. A 3-row data frame where y is recycled to 1 2 1
  2. An error: arguments imply differing number of rows: 3, 2
  3. A 3-row data frame where the last y is NA
  4. A 2-row data frame (x is truncated)
35Средний
What does this code print?
df <- data.frame(a = 1:3, b = 4:6)
c(class(df[, 2]), class(df[2, ]))
  1. [1] "data.frame" "data.frame"
  2. [1] "integer" "integer"
  3. [1] "data.frame" "integer"
  4. [1] "integer" "data.frame"
36Сложный
What does this code print?
a <- data.frame(id = c(1, 2, 3), x = c("p", "q", "r"))
b <- data.frame(id = c(2, 3, 4), y = c(TRUE, FALSE, TRUE))
c(nrow(merge(a, b)), nrow(merge(a, b, all = TRUE)))
  1. [1] 3 4
  2. [1] 2 6
  3. [1] 2 4
  4. [1] 3 3
Functions and scoping9
37Лёгкий
What does f(3) return?
f <- function(x, y = 2) x^y
f(3)
  1. [1] 6
  2. [1] 9
  3. [1] 8
  4. Error: argument "y" is missing
38Лёгкий
What does the last line print?
x <- 1
f <- function() {
  x <- 2
  invisible(x)
}
f()
x
  1. [1] 2
  2. NULL
  3. Error: object x is locked
  4. [1] 1
39Средний
What does this call return?
f <- function(a, b) a * 2
f(3, stop("boom"))
  1. Error: boom
  2. [1] 6
  3. Error: unused argument
  4. [1] NA
40Средний
What does this call return?
f <- function(value, verbose = FALSE) value
f(val = 3)
  1. Error: unused argument (val = 3)
  2. Error: argument "value" is missing, with no default
  3. [1] 3
  4. [1] FALSE
41Сложный
What does the last line print?
make_counter <- function() {
  i <- 0
  function() {
    i <<- i + 1
    i
  }
}
c1 <- make_counter()
c1()
c1()
c2 <- make_counter()
c(c2(), c1())
  1. [1] 1 3
  2. [1] 3 4
  3. [1] 1 1
  4. [1] 3 3
42Лёгкий
What does f(5) return?
f <- function(x) {
  x + 1
  x * 2
}
f(5)
  1. [1] 10
  2. [1] 6
  3. [1] 6 10
  4. NULL
43Средний
What does g() return?
x <- 10
f <- function() x
g <- function() {
  x <- 20
  f()
}
g()
  1. [1] 20
  2. Error: object x not found
  3. NULL
  4. [1] 10
44Средний
What does this call return?
f <- function(...) length(list(...))
f(1, "a", NULL)
  1. [1] 3
  2. [1] 2
  3. [1] 1
  4. Error: NULL is not allowed in ...
45Сложный
What does f(1) return?
f <- function(x, y = x * 2) {
  x <- 100
  y
}
f(1)
  1. [1] 2
  2. [1] 100
  3. [1] 200
  4. Error: object x not found
Control flow and apply family9
46Лёгкий
What does this code print?
sapply(1:3, function(i) i^2)
  1. [1] 1 4 9
  2. [1] 2 4 6
  3. [[1]]
    [1] 1

    [[2]]
    [1] 4

    [[3]]
    [1] 9
  4. [1] 14
47Лёгкий
What does this code print?
res <- 0
for (i in 1:5) {
  if (i %% 2 == 0) next
  res <- res + i
}
res
  1. [1] 9
  2. [1] 6
  3. [1] 15
  4. [1] 1
48Средний
What does this code print?
mapply(function(x, y) x + y, 1:3, 4:6)
  1. [1] 5 7 9
  2. [1] 21
  3. [1] 5 6 7 6 7 8 7 8 9
  4. Error: FUN must take one argument
49Сложный
What happens when this code runs?
vapply(1:3, function(i) i * 2, character(1))
  1. It returns "2" "4" "6"
  2. It returns 2 4 6
  3. An error: values must be type 'character', but the result is type 'double'
  4. It returns a list of three numbers
50Лёгкий
What does this code print?
ifelse(c(1, 5, 10) > 4, "big", "small")
  1. [1] "big"
  2. [1] "small"
  3. Error: the condition has length > 1
  4. [1] "small" "big" "big"
51Лёгкий
What does this code print?
class(lapply(1:2, function(i) i * 10))
  1. [1] "list"
  2. [1] "numeric"
  3. [1] "integer"
  4. [1] "matrix" "array"
52Средний
In R 4.2 or later, what happens here?
if (c(TRUE, FALSE)) "yes"
  1. It returns "yes", using only the first element
  2. It returns "yes" twice
  3. It returns NULL
  4. An error: the condition has length > 1
53Средний
What does this code print?
dim(sapply(1:3, function(i) c(i, i^2)))
  1. [1] 3 2
  2. NULL
  3. [1] 2 3
  4. [1] 6
54Сложный
What does this code print?
switch("b", a = 1, b = , c = 3)
  1. NULL
  2. [1] 1
  3. [1] 3
  4. Error: empty alternative in switch
Strings and regex9
55Лёгкий
What does this code print?
c(paste("a", "b"), paste0("a", "b"))
  1. [1] "ab" "ab"
  2. [1] "a b" "a b"
  3. [1] "a b" "ab"
  4. [1] "ab" "a b"
56Лёгкий
What does this code print?
sprintf("%.2f", 2/3)
  1. [1] "0.67"
  2. [1] "0.66"
  3. [1] 0.67
  4. [1] "0.666666666666667"
57Средний
What does this code print?
paste(c("x", "y"), 1:2, sep = "_", collapse = "+")
  1. [1] "x_1" "y_2"
  2. [1] "x+1_y+2"
  3. [1] "x_y_1_2"
  4. [1] "x_1+y_2"
58Средний
What does this code print?
grepl("^R", c("R lang", "lang R", "r"))
  1. [1] TRUE TRUE TRUE
  2. [1] TRUE FALSE FALSE
  3. [1] TRUE TRUE FALSE
  4. [1] 1
59Сложный
What does this code print?
s <- "a1b22c333"
regmatches(s, gregexpr("[0-9]+", s))[[1]]
  1. [1] "1"
  2. [1] "122333"
  3. [1] "1" "22" "333"
  4. [1] 1 22 333
60Лёгкий
What does this code print?
c(nchar("hello"), length("hello"))
  1. [1] 5 5
  2. [1] 1 1
  3. [1] 1 5
  4. [1] 5 1
61Лёгкий
What does this code print?
strsplit("a,b,c", ",")[[1]][2]
  1. [1] "a"
  2. [1] "b"
  3. [1] ","
  4. Error: subscript out of bounds
62Средний
What does this code print?
c(sub("a", "o", "banana"), gsub("a", "o", "banana"))
  1. [1] "bonono" "bonono"
  2. [1] "bonana" "bonana"
  3. [1] "bonana" "bonono"
  4. [1] "banano" "bonono"
63Сложный
What does this code print?
gsub(".", "-", "a.b")
  1. [1] "---"
  2. [1] "a-b"
  3. [1] "a.b"
  4. [1] "-.b"
Statistics and distributions9
64Лёгкий
What does this code print?
x <- c(1, NA, 3)
c(mean(x), mean(x, na.rm = TRUE))
  1. [1] 2 2
  2. [1] NA 2
  3. [1] 1.333333 2
  4. Error: missing values in x
65Лёгкий
What does rnorm(100, 5) generate?
  1. 100 values from a normal distribution with mean 0 and standard deviation 5
  2. 100 values from a normal distribution with mean 5 and standard deviation 1
  3. 5 values with mean 100
  4. 100 values with mean 5 and variance 5
66Средний
For Z ~ N(0, 1), which call returns P(Z > 2)?
  1. dnorm(2)
  2. qnorm(2)
  3. pnorm(2, lower.tail = FALSE)
  4. 1 - dnorm(2)
67Сложный
With R's default quantile type, what does this print?
quantile(1:10, 0.25)
  1. 3 (labelled 25%)
  2. 3.25 (labelled 25%)
  3. 2.75 (labelled 25%)
  4. 2.5 (labelled 25%)
68Лёгкий
What does this code print?
x <- c(2, 4, 9)
c(mean(x), median(x))
  1. [1] 4 5
  2. [1] 5 4
  3. [1] 5 5
  4. [1] 15 4
69Лёгкий
What does this code print?
set.seed(42); a <- runif(3)
set.seed(42); b <- runif(3)
identical(a, b)
  1. [1] TRUE
  2. [1] FALSE
  3. It depends on the computer clock
  4. Error: seed already set
70Средний
Approximately what does qnorm(0.975) return?
  1. 0.835
  2. 0.975
  3. 1.96
  4. 2.58
71Средний
What does sd() return here (rounded)?
sd(c(2, 4, 4, 4, 5, 5, 7, 9))
  1. 2.138
  2. 2
  3. 4
  4. 4.571
72Сложный
What is pbinom(2, size = 5, prob = 0.5)?
  1. 0.5
  2. 0.3125
  3. 0.8125
  4. 0.1875
Models9
73Лёгкий
In lm(y ~ x1 + x2, data = d), which variable is the response (dependent variable)?
  1. x1
  2. x2
  3. x1 and x2 together
  4. y
74Лёгкий
Which formula fits a regression of y on x without an intercept?
  1. y ~ x - 1
  2. y ~ x + 1
  3. y ~ x + 0 + 1
  4. y ~ I(x - 1)
75Средний
What does the last line return?
d <- data.frame(x = 1:5, y = c(3, 5, 7, 9, 11))
fit <- lm(y ~ x, data = d)
predict(fit, newdata = data.frame(x = 10))
  1. 11
  2. 21 (named "1")
  3. The 5 fitted values for the original data
  4. 10
76Сложный
Why is I() needed in lm(y ~ x + I(x^2))?
  1. I() marks x^2 as an integer variable
  2. I() makes the term independent of x so they are not collinear
  3. Inside a formula ^ means crossing of terms, so x^2 alone would just be x; I() makes it arithmetic squaring
  4. It is not needed: y ~ x + x^2 fits the same quadratic model
77Сложный
fit <- glm(y ~ x, family = binomial, data = d). What does predict(fit, newdata = nd) return by default?
  1. Predicted probabilities between 0 and 1
  2. Predicted log-odds (the linear predictor)
  3. Predicted classes 0 or 1
  4. Predicted odds
78Лёгкий
What are the fitted coefficients?
x <- 1:5
y <- 2 * x + 1
coef(lm(y ~ x))
  1. Intercept 2, slope 1
  2. Intercept 0, slope 2
  3. Only a slope of about 2.27 (no intercept)
  4. Intercept 1, slope 2
79Средний
The formula y ~ a * b is equivalent to which formula?
  1. y ~ a:b
  2. y ~ a + b + a:b
  3. y ~ I(a * b)
  4. y ~ a + b
80Средний
fit <- lm(y ~ x, data = d). Which expression returns the model's R²?
  1. fit$r.squared
  2. summary(fit)$r.squared
  3. coef(fit)["r.squared"]
  4. anova(fit)$R2
81Сложный
g is a factor with levels "a", "b", "c". What coefficient names does coef(lm(y ~ g)) have?
  1. "ga" "gb" "gc"
  2. "(Intercept)" "gb" "gc"
  3. "(Intercept)" "ga" "gb" "gc"
  4. "(Intercept)" "g"
Packages and the tidyverse9
82Лёгкий
Which dplyr verb chooses columns (variables) rather than rows?
  1. filter()
  2. select()
  3. arrange()
  4. summarise()
83Лёгкий
In ggplot2, how are layers combined into one plot?
  1. With the pipe |>, e.g. ggplot(d, aes(x, y)) |> geom_point()
  2. With +, e.g. ggplot(d, aes(x, y)) + geom_point()
  3. By passing them as a list to print()
  4. With %>%, e.g. ggplot(d, aes(x, y)) %>% geom_point()
84Средний
What does this code print?
library(dplyr)
tibble(x = 1:3) |>
  mutate(y = x * 2, z = y + 1) |>
  pull(z)
  1. [1] 3 5 7
  2. [1] 2 3 4
  3. Error: object 'y' not found
  4. [1] 2 4 6
85Сложный
What happens in this plot?
ggplot(d, aes(x, y, color = "blue")) +
  geom_point()
  1. All points are blue and there is no legend
  2. Points get ggplot2's first default hue (reddish) and a legend shows the label "blue"
  3. An error: "blue" is not a column of d
  4. The points are invisible
86Лёгкий
The dplyr package is already installed. Which line makes its functions available in the current session?
  1. install.packages("dplyr")
  2. library(dplyr)
  3. source("dplyr")
  4. import dplyr
87Лёгкий
What does this code print (R 4.1 or later)?
c(1, 4, 9) |> sqrt() |> sum()
  1. [1] 6
  2. [1] 3.741657
  3. [1] 1 2 3
  4. [1] 14
88Средний
How many rows does the result have?
library(dplyr)
mtcars |>
  group_by(cyl) |>
  summarise(n = n())
  1. 32
  2. 1
  3. 11
  4. 3
89Сложный
How many rows does the result have?
library(dplyr)
tibble(x = c(1, NA, 3)) |>
  filter(x > 1) |>
  nrow()
  1. 1
  2. 2
  3. 3
  4. Error: missing values in filter()
90Сложный
Which line correctly passes a data frame d into the data argument of lm() using the native pipe (R 4.2+)?
  1. d |> lm(y ~ x)
  2. d |> lm(y ~ x, data = .)
  3. d |> lm(y ~ x, _)
  4. d |> lm(y ~ x, data = _)
Gotchas10
91Лёгкий
What does this code print?
0.1 + 0.2 == 0.3
  1. [1] TRUE
  2. [1] NA
  3. [1] FALSE
  4. Error: cannot compare doubles
92Средний
x is an empty vector. How many times does this loop print?
x <- c()
for (i in 1:length(x)) print(i)
  1. Never
  2. Once: it prints 0
  3. It stops with an error
  4. Twice: it prints 1 and then 0
93Средний
What does this code print?
T <- FALSE
if (T) "yes" else "no"
  1. [1] "yes"
  2. Error: cannot change value of locked binding for T
  3. Error: invalid argument
  4. [1] "no"
94Средний
What does this code return?
max(numeric(0))
  1. -Inf, with a warning
  2. NA
  3. 0
  4. NULL
95Сложный
What does this code print?
seq(0, 1, by = 0.1)[4] == 0.3
  1. [1] FALSE
  2. [1] TRUE
  3. [1] NA
  4. Error: subscript out of bounds
96Лёгкий
What does this code print?
identical(1L, 1)
  1. [1] TRUE
  2. [1] FALSE
  3. [1] NA
  4. Error: different types
97Средний
What does this code print?
x <- numeric(0)
length(seq_along(x))
  1. [1] 0
  2. [1] 1
  3. [1] 2
  4. Error: x is empty
98Средний
What does this code print?
-2^2
  1. [1] -4
  2. [1] 4
  3. [1] NaN
  4. Error: unexpected ^
99Сложный
What does this code print?
f <- factor(c("10", "20", "10"))
as.numeric(f)
  1. [1] 10 20 10
  2. [1] NA NA NA
  3. [1] "10" "20" "10"
  4. [1] 1 2 1
100Сложный
What does this code print?
mean(1, 2, 3)
  1. [1] 2
  2. [1] 1
  3. [1] 6
  4. Error: unused arguments (2, 3)

Как проходить тест

  • Выберите темы и уровень — лёгкий уровень проверяет определения и задачи в одно действие, средний — стандартные вычисления, сложный — многошаговые задачи и теорию.
  • Отвечайте касанием или с клавиатуры: 1–4 или A–D, Enter — следующий вопрос.
  • Читайте объяснения — после ошибки разбор открывается сразу, после верного ответа его можно раскрыть кнопкой «Почему».
  • Работайте над ошибками — «Повторить ошибки» в конце теста или режим «Только мои ошибки» потом: ответы запоминаются в этом браузере.

Незавершённый тест сохраняется — после перезагрузки страницы можно продолжить с того же вопроса.

Темы теста

  • Vectors and recycling 9
  • Data types and coercion 9
  • Indexing and subsetting 9
  • Lists and data frames 9
  • Functions and scoping 9
  • Control flow and apply family 9
  • Strings and regex 9
  • Statistics and distributions 9
  • Models 9
  • Packages and the tidyverse 9
  • Gotchas 10