```{r setup, include=FALSE}
library(learnr)
library(xfun)
```

```{r quiz1, echo=FALSE}
question("What is the purpose of the RStudio IDE mentioned in the text?",
  answer("A. It is used to download and install the latest version of R."),
  answer("B. It is used to create and save R scripts."),
  answer("C. It is used to run R codes and view outputs.", correct = TRUE),
  answer("D. It is used to generate random numbers from the normal distribution."),
  allow_retry = TRUE
)

```

```{r quiz2, echo=FALSE}
question("Which function is used to set a seed for reproducibility in random number generation?",
  answer("A. set.seed()", correct = TRUE),
  answer("B. exp()"),
  answer("C. rnorm()"),
  answer("D. curve()"),
  allow_retry = TRUE
)

```

```{r quiz3, echo=FALSE}
question("How can you change the name of variables/columns in a data frame?",
  answer("A. Using the colnames() function", correct = TRUE),
  answer("B. Using the dim() function"),
  answer("C. Using the rbind() function"),
  answer("D. Using the for loop function"),
  allow_retry = TRUE
)
```

```{r quiz4, echo=FALSE}
question("If we set the seed to 11 and generate 10 random numbers from a normal distribution, will we get the same result each time we run it? (Hint: Think about the purpose of setting a seed.)",
  answer("Yes", correct = TRUE),
  answer("No"),
  allow_retry = TRUE
)


```

```{r quiz5, echo=FALSE}
question("How can you change the column names of a data frame called df to 'Studyid', 'Grade', and 'Sex' in R?",
  answer("A. names(df) <- c('Studyid', 'Grade', 'Sex')"),
  answer("B. colnames(df) <- c('Studyid', 'Grade', 'Sex')", correct = TRUE),
  answer("C. df$names <- c('Studyid', 'Grade', 'Sex')"),
  answer("D. df$colnames <- c('Studyid', 'Grade', 'Sex')"),
  allow_retry = TRUE
)

```

```{r quiz6, echo=FALSE}
question("How can you extract the value from the first row and first column of a data frame called df in R?",
  answer("A. df[0, 0]"),
  answer("B. df[1, 1]", correct = TRUE),
  answer("C. df[0][0]"),
  answer("D. df[1][1]"),
  allow_retry = TRUE
)

```

```{r quiz7, echo=FALSE}
question("How can you combine two matrices into a list in R?",
  answer("A. c(matrix1, matrix2)"),
  answer("B. list(matrix1, matrix2)", correct = TRUE),
  answer("C. combine(matrix1, matrix2)"),
  answer("D. join(matrix1, matrix2)"),
  allow_retry = TRUE
)

```

```{r quiz8, echo=FALSE}
question("How do you create a matrix with 5 rows and 2 columns filled by rows in R?",
  answer("A. matrix(x, rows = 5, cols = 2, byrow = TRUE)"),
  answer("B. matrix(x, nrows = 5, ncols = 2, byrow = TRUE)", correct = TRUE),
  answer("C. matrix(x, r = 5, c = 2, byrow = TRUE)"),
  answer("D. matrix(x, nrow = 5, ncol = 2, byrow = TRUE)"),
  allow_retry = TRUE
)

```

```{r quiz9, echo=FALSE}
question("How do you create a vector with values ranging from 0 to 100 in steps of 10 in R?",
  answer("A. c(0, 100, 10)"),
  answer("B. seq(0, 100, 10)", correct = TRUE),
  answer("C. seq(from = 0, to = 100, by = 10)"),
  answer("D. range(0, 100, 10)"),
  allow_retry = TRUE
)

```

```{r quiz10, echo=FALSE}
question("How can you set a seed to ensure reproducible results in R?",
  answer("A. seed(11)"),
  answer("B. rnorm(seed = 11)"),
  answer("C. set.seed(11)", correct = TRUE),
  answer("D. random.seed(11)"),
  allow_retry = TRUE
)

```

```{r quiz11, echo=FALSE}
question("What is the output of the command exp(2)?",
  answer("A. 2"),
  answer("B. 7.389056", correct = TRUE),
  answer("C. 1"),
  answer("D. 10"),
  allow_retry = TRUE
)

```

```{r quiz12, echo=FALSE}
question("If x1 <- 2 and y1 <- x1^2, what is the value of y1?",
  answer("A. 2"),
  answer("B. 4", correct = TRUE),
  answer("C. 1"),
  answer("D. 8"),
  allow_retry = TRUE
)

```
