bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

README.md (21031B)


      1 # R Programming: Last-Minute Exam Cheat Sheet
      2 
      3 This document is designed for rapid review before your exam. It covers essential core concepts, crucial R functions (and their quirks), and all 20 reserved words.
      4 
      5 ## Crucial Rules to Remember
      6 
      7 1. **Variable Naming:** Variables can start with letters or a period (`.`). However, if they start with a period, they **cannot** be followed by a digit (`.2var` is illegal).
      8 2. **1-Based Indexing:** Unlike C, Python, or Java (where arrays start at 0), **R indices start at 1**. The first element of `vector_x` is `vector_x[1]`.
      9 3. **Negative Indexing:** Using a minus sign *excludes* that element. `my_list[-2]` returns the list WITHOUT the 2nd element.
     10 4. **Type Coercion:** If you mix data types in a vector (e.g., `c(1, "A", TRUE)`), R will aggressively force them into a single type. The hierarchy is: `logical` -> `integer` -> `numeric` -> `character`.
     11 5. **Returning Multiple Values:** A function can only return ONE object. To return multiple answers, bundle them into a list: `return(list("Area"=area, "Perimeter"=peri))`.
     12 6. **Assignment:** While `=` works, `<-` is the strictly preferred assignment operator in R. `=` is mainly used for assigning arguments inside function calls.
     13 7. **Null vs NA vs NaN:** 
     14    - `NA`: Missing data (Not Available).
     15    - `NaN`: Mathematical impossibility (Not a Number, like `0/0`).
     16    - `NULL`: An empty object / undefined.
     17 
     18 ## Essential Operators
     19 
     20 | Operator | Name | Category | Description |
     21 | :--- | :--- | :--- | :--- |
     22 | `<-` | Left Assignment | Assignment | Assigns a value to a variable (Leftward). |
     23 | `->` | Right Assignment | Assignment | Assigns a value to a variable (Rightward). |
     24 | `%%` | Modulo | Arithmetic | Modulo (finds the remainder of division, e.g., `5 %% 2 == 1`). |
     25 | `^` | Exponent | Arithmetic | Exponent/Power (e.g., `2^3 == 8`). |
     26 | `<` / `>` | Less/Greater Than | Relational | Strictly less than / strictly greater than. |
     27 | `<=` / `>=` | Less/Greater or Equal | Relational | Less than or equal to / Greater than or equal to. |
     28 | `==` / `!=` | Equality / Inequality | Relational | Equals to / Not equals to. |
     29 | `&` | Element-wise AND | Logical | Element-wise AND (returns TRUE only if both are TRUE). |
     30 | `&&` | Logical AND | Logical | Evaluates ONLY the first element of a vector. Used mainly in if-statements. |
     31 | `|` | Element-wise OR | Logical | Element-wise OR (returns TRUE if at least one is TRUE). |
     32 | `||` | Logical OR | Logical | Evaluates ONLY the first element of a vector. Used mainly in if-statements. |
     33 | `!` | Logical NOT | Logical | NOT operator (reverses a boolean, `!TRUE == FALSE`). |
     34 
     35 ---
     36 
     37 ## Built-In Constants
     38 
     39 | Constant | Value | Description |
     40 | :--- | :--- | :--- |
     41 | `pi` | `3.141593...` | The mathematical constant pi. |
     42 | `LETTERS` | `"A", "B", "C" ... "Z"` | A character vector of the 26 uppercase English letters. |
     43 | `letters` | `"a", "b", "c" ... "z"` | A character vector of the 26 lowercase English letters. |
     44 | `month.abb` | `"Jan", "Feb" ... "Dec"` | A character vector of the 3-letter abbreviations for the English months. |
     45 | `month.name` | `"January", "February"...` | A character vector of the full names of the English months. |
     46 
     47 ---
     48 
     49 ## All 20 R Reserved Words (Keywords)
     50 
     51 Reserved words have special meaning in R and **cannot** be used as variable or function names.
     52 
     53 | Reserved Word | Usage / Description | Quick Example |
     54 | :--- | :--- | :--- |
     55 | `if` | Starts a conditional control-flow statement. | `if (x > 0) print("Pos")` |
     56 | `else` | Fallback for an `if` statement when the condition is FALSE. | `else print("Neg")` |
     57 | `while` | Loop that executes as long as a condition is TRUE. | `while (x < 5) x <- x + 1` |
     58 | `repeat` | Infinite loop that requires a `break` statement to exit. | `repeat { if(x>5) break }` |
     59 | `for` | Loop that iterates over a list, vector, or sequence. | `for (i in 1:5) print(i)` |
     60 | `function` | Keyword used to declare a user-defined function. | `f <- function(x) { x + 1 }` |
     61 | `in` | Used within `for` loops to specify the sequence to iterate over. | `for (item in my_list)` |
     62 | `next` | Skips the current loop iteration and moves to the next one. | `if (i %% 2 == 0) next` |
     63 | `break` | Immediately terminates the execution of a loop. | `if (i == 5) break` |
     64 | `TRUE` | Logical constant representing True (boolean 1). | `is_valid <- TRUE` |
     65 | `FALSE` | Logical constant representing False (boolean 0). | `is_valid <- FALSE` |
     66 | `NULL` | Represents the null object / undefined data. | `my_var <- NULL` |
     67 | `Inf` | Constant representing positive infinity. | `1 / 0` -> `Inf` |
     68 | `NaN` | Not a Number (e.g., 0/0). | `0 / 0` -> `NaN` |
     69 | `NA` | Logical missing value (Not Available). | `c(1, NA, 3)` |
     70 | `NA_integer_` | Missing value specifically typed as an integer. | `c(1L, NA_integer_)` |
     71 | `NA_real_` | Missing value specifically typed as a double/numeric. | `c(1.5, NA_real_)` |
     72 | `NA_complex_` | Missing value specifically typed as a complex number. | `c(1+2i, NA_complex_)` |
     73 | `NA_character_` | Missing value specifically typed as a character/string. | `c("A", NA_character_)` |
     74 | `...` | Ellipsis operator used to pass a variable number of arguments into a function. | `f <- function(...) print(list(...))` |
     75 
     76 ---
     77 
     78 ## Essential Functions Reference
     79 
     80 | Function | Usage | Example Result-Output | Edge Case / Quirks |
     81 | :--- | :--- | :--- | :--- |
     82 | `print()` | Prints values and variables to the console. | `print("R")`  ->  `[1] "R"` | Printing `NULL` prints `NULL` (without the `[1]` index). |
     83 | `cat()` | Prints variables and strings concatenated, used with basic types. | `cat("Hi\n")`  ->  `Hi` | `cat(NULL)` outputs absolutely nothing, no errors. |
     84 | `help()` | Views help documentation for functions or keywords. | `help(sum)`  ->  *(Opens help viewer)* | Searching for special operators requires backticks: `help("+")`. |
     85 | `class()` | Returns the data type or class of a variable. | `class(TRUE)`  ->  `[1] "logical"` | If applied to a mixed vector `c(1, "a")`, returns `"character"` (coercion). |
     86 | `paste()` | Prints a string and variable together with a default space separator. | `paste("Hi", "R")`  ->  `[1] "Hi R"` | `paste("A", NA)` outputs `"A NA"` (NA is converted to a string). |
     87 | `paste0()` | Prints a string and variable together with NO default space separator. | `paste0("Hi", "R")`  ->  `[1] "HiR"` | Recycles shorter vectors: `paste0("A", 1:3)` -> `"A1" "A2" "A3"`. |
     88 | `sprintf()` | Prints formatted strings using format specifiers like %s, %d, %f. | `sprintf("%d", 123)`  ->  `[1] "123"` | Throws an error if the number of arguments doesn't match specifiers. |
     89 | `is.numeric()` | Evaluates to TRUE if the variable is of numeric type. | `is.numeric(5)`  ->  `[1] TRUE` | `is.numeric(NA)` is logical, but `is.numeric(NA_real_)` is TRUE. |
     90 | `ifelse()` | A shorthand vectorized alternative to the standard if...else statement. | `ifelse(c(1) > 0, "Y", "N")`  ->  `[1] "Y"` | If the condition evaluates to `NA`, the output element will be `NA`. |
     91 | `c()` | Combines or concatenates values into a vector. | `c(1, 2)`  ->  `[1] 1 2` | Mix types (e.g. number + string) and everything becomes strings. |
     92 | `rep()` | Repeats elements of vectors using 'times' or 'each' arguments. | `rep(2, times=2)`  ->  `[1] 2 2` | `rep(1, times=0)` returns an empty vector: `numeric(0)`. |
     93 | `length()` | Finds the number of elements present inside a vector or list. | `length(c(1, 2))`  ->  `[1] 2` | `length(NULL)` evaluates to `0`. |
     94 | `list()` | Creates a collection of similar or different types of data. | `list(1, "A")`  ->  `[[1]] 1  [[2]] "A"` | A list can contain lists inside itself (nested lists). |
     95 | `append()` | Adds an item at the end of a list or vector. | `append(c(1), 2)`  ->  `[1] 1 2` | Does not modify the original variable in-place; must reassign. |
     96 | `factorial()` | Calculates the factorial value of a number or vector. | `factorial(4)`  ->  `[1] 24` | `factorial(0)` returns `1`. `factorial(-1)` returns `NaN`. |
     97 | `sum()` | Finds the sum of a sequence of numbers. | `sum(1, 2)`  ->  `[1] 3` | `sum(c(1, NA))` is `NA`. Use `na.rm=TRUE` to ignore NAs. |
     98 | `max()` / `min()` | Finds the maximum/minimum value in a sequence of numbers. | `max(4:6)`  ->  `[1] 6` | `max(numeric(0))` returns `-Inf` and a warning message. |
     99 | `seq()` | Generates regular sequences (more flexible than the `:` operator). | `seq(1, 5, by=2)` -> `[1] 1 3 5` | `seq(1, 1)` correctly handles start and end being the same. |
    100 | `mean()` | Calculates the arithmetic mean (average). | `mean(c(2, 4))` -> `[1] 3` | `mean(c(1, NA))` returns `NA`. Requires `na.rm = TRUE`. |
    101 | `is.na()` | Checks for missing values (`NA`) and returns a logical vector. | `is.na(c(1, NA))` -> `[1] FALSE TRUE` | `is.na(NaN)` also evaluates to `TRUE` in R. |
    102 | `str()` | Compactly displays the internal structure of an R object. | `str(c(1,2))` -> `num [1:2] 1 2` | Calling `str(NULL)` safely returns ` NULL`. |
    103 | `typeof()` | Determines the internal R type or storage mode of any object. | `typeof(1L)` -> `[1] "integer"` | `typeof(c(1, 2))` returns `"double"`, while `class` is `"numeric"`. |
    104 | `rm()` | Removes objects/variables from the current workspace environment. | `rm(x)` -> *(Removes x)* | `rm(list = ls())` completely clears the entire workspace. |
    105 
    106 ---
    107 
    108 ## 55 Practice Questions (Basic to Advanced)
    109 
    110 Test your knowledge! Click on any question to reveal the answer.
    111 
    112 <details>
    113 <summary><b>Q1: What is the primary difference between `<-` and `=` in R?</b></summary>
    114 
    115 > `<-` is the standard assignment operator for variables. `=` is typically used only for assigning values to parameters inside function calls.
    116 
    117 </details>
    118 <br>
    119 
    120 <details>
    121 <summary><b>Q2: Can you assign a variable from right to left in R?</b></summary>
    122 
    123 > Yes, R supports rightward assignment using `->` (e.g., `"Hello" -> my_var`).
    124 
    125 </details>
    126 <br>
    127 
    128 <details>
    129 <summary><b>Q3: How do you write a true multi-line comment in R?</b></summary>
    130 
    131 > R does not have a native multi-line comment syntax. You must either use `#` on every line or wrap text in a dummy `if (FALSE) { ... }` block.
    132 
    133 </details>
    134 <br>
    135 
    136 <details>
    137 <summary><b>Q4: What is the difference between `class(14)` and `class(14L)`?</b></summary>
    138 
    139 > `14` is a floating-point `numeric` by default. The `L` suffix explicitly declares `14L` as an `integer`.
    140 
    141 </details>
    142 <br>
    143 
    144 <details>
    145 <summary><b>Q5: Is R case-sensitive? Give an example.</b></summary>
    146 
    147 > Yes. `TRUE` is a valid boolean keyword, but `True` or `true` will throw an 'object not found' error.
    148 
    149 </details>
    150 <br>
    151 
    152 <details>
    153 <summary><b>Q6: What happens if you type `T <- FALSE`?</b></summary>
    154 
    155 > It will successfully overwrite `T` to mean `FALSE`. This is why using `TRUE`/`FALSE` is safer than the `T`/`F` shorthands, as the full words are reserved and cannot be overwritten.
    156 
    157 </details>
    158 <br>
    159 
    160 <details>
    161 <summary><b>Q7: What is the exact output of `paste("Hello", "R")`?</b></summary>
    162 
    163 > `"Hello R"`. The standard `paste()` function adds a single space between items by default.
    164 
    165 </details>
    166 <br>
    167 
    168 <details>
    169 <summary><b>Q8: What is the exact output of `paste0("Hello", "R")`?</b></summary>
    170 
    171 > `"HelloR"`. The `paste0()` function explicitly concatenates with no spaces.
    172 
    173 </details>
    174 <br>
    175 
    176 <details>
    177 <summary><b>Q9: If `x <- 12.34`, what does `sprintf("Value: %f", x)` do?</b></summary>
    178 
    179 > It formats the float as a string, outputting `"Value: 12.340000"`.
    180 
    181 </details>
    182 <br>
    183 
    184 <details>
    185 <summary><b>Q10: Why can't you use `cat()` to print a list?</b></summary>
    186 
    187 > `cat()` only works with basic atomic types (logical, integer, numeric, character). It cannot handle complex data structures like lists.
    188 
    189 </details>
    190 <br>
    191 
    192 <details>
    193 <summary><b>Q11: What happens when you run `c(1, "A", TRUE)`?</b></summary>
    194 
    195 > R coerces them all to the most flexible type (character). The output is `"1" "A" "TRUE"`.
    196 
    197 </details>
    198 <br>
    199 
    200 <details>
    201 <summary><b>Q12: What does `is.numeric(NA)` return?</b></summary>
    202 
    203 > `[1] logical`. Standard `NA` is a logical type by default, unless specified as `NA_real_`.
    204 
    205 </details>
    206 <br>
    207 
    208 <details>
    209 <summary><b>Q13: How is `ifelse()` different from a standard `if...else` block?</b></summary>
    210 
    211 > `ifelse()` is vectorized, meaning it can evaluate an entire vector of conditions at once and return a vector of results. `if...else` evaluates a single condition.
    212 
    213 </details>
    214 <br>
    215 
    216 <details>
    217 <summary><b>Q14: What happens if you pass a vector of length 5 into a standard `if (condition)` statement?</b></summary>
    218 
    219 > The `if` statement will only evaluate the very first element of the vector and will throw a warning.
    220 
    221 </details>
    222 <br>
    223 
    224 <details>
    225 <summary><b>Q15: What does the `%%` operator do?</b></summary>
    226 
    227 > It calculates the modulo (remainder of division). E.g., `5 %% 2` equals `1`.
    228 
    229 </details>
    230 <br>
    231 
    232 <details>
    233 <summary><b>Q16: When does a `while` loop terminate?</b></summary>
    234 
    235 > When its test condition evaluates to `FALSE`, or when a `break` statement is encountered inside the loop.
    236 
    237 </details>
    238 <br>
    239 
    240 <details>
    241 <summary><b>Q17: If a `break` statement is executed inside a nested loop, what happens?</b></summary>
    242 
    243 > It immediately terminates *only the innermost loop* where the `break` was called. The outer loop continues running.
    244 
    245 </details>
    246 <br>
    247 
    248 <details>
    249 <summary><b>Q18: What does the `next` statement do?</b></summary>
    250 
    251 > It immediately skips the rest of the current loop iteration and jumps to the evaluation of the next iteration.
    252 
    253 </details>
    254 <br>
    255 
    256 <details>
    257 <summary><b>Q19: What is the index of the first element in an R vector?</b></summary>
    258 
    259 > `1`. Unlike Python or C, R uses 1-based indexing.
    260 
    261 </details>
    262 <br>
    263 
    264 <details>
    265 <summary><b>Q20: What does negative indexing do, e.g., `my_vector[-2]`?</b></summary>
    266 
    267 > It returns all elements of the vector *except* the element at index 2.
    268 
    269 </details>
    270 <br>
    271 
    272 <details>
    273 <summary><b>Q21: What is the output of `length(NULL)`?</b></summary>
    274 
    275 > It returns `0`, because `NULL` represents an empty, undefined object.
    276 
    277 </details>
    278 <br>
    279 
    280 <details>
    281 <summary><b>Q22: What is the output of `length(NA)`?</b></summary>
    282 
    283 > It returns `1`. `NA` represents a single missing value, so it still takes up one slot in memory.
    284 
    285 </details>
    286 <br>
    287 
    288 <details>
    289 <summary><b>Q23: What is the difference between `1:3` and `c(1, 2, 3)`?</b></summary>
    290 
    291 > Practically nothing in the output, but `:` is a sequence generator operator that efficiently creates the integer sequence without explicitly typing each element.
    292 
    293 </details>
    294 <br>
    295 
    296 <details>
    297 <summary><b>Q24: What is the output of `rep(c(1, 2), times = 2)`?</b></summary>
    298 
    299 > `1 2 1 2`. It repeats the entire sequence twice.
    300 
    301 </details>
    302 <br>
    303 
    304 <details>
    305 <summary><b>Q25: What is the output of `rep(c(1, 2), each = 2)`?</b></summary>
    306 
    307 > `1 1 2 2`. It repeats each individual element twice before moving to the next.
    308 
    309 </details>
    310 <br>
    311 
    312 <details>
    313 <summary><b>Q26: How do you permanently change the 2nd element of `x` to 5?</b></summary>
    314 
    315 > `x[2] <- 5`.
    316 
    317 </details>
    318 <br>
    319 
    320 <details>
    321 <summary><b>Q27: What is the fundamental difference between a Vector and a List?</b></summary>
    322 
    323 > A vector can only hold elements of the *same* data type. A list can hold elements of *different* data types (strings, numbers, booleans, or even other lists).
    324 
    325 </details>
    326 <br>
    327 
    328 <details>
    329 <summary><b>Q28: Does `append(my_list, 5)` permanently change `my_list`?</b></summary>
    330 
    331 > No. Most functions in R do not modify in-place. You must overwrite the variable: `my_list <- append(my_list, 5)`.
    332 
    333 </details>
    334 <br>
    335 
    336 <details>
    337 <summary><b>Q29: How do you extract the actual value of the first element in a list, not just a sub-list?</b></summary>
    338 
    339 > Using double brackets: `my_list[[1]]`. Single brackets `my_list[1]` return a new list containing that element.
    340 
    341 </details>
    342 <br>
    343 
    344 <details>
    345 <summary><b>Q30: What keyword is used to create a custom function?</b></summary>
    346 
    347 > `function()`. Example: `my_func <- function(x) { ... }`.
    348 
    349 </details>
    350 <br>
    351 
    352 <details>
    353 <summary><b>Q31: What is a formal argument vs an actual argument?</b></summary>
    354 
    355 > Formal arguments are the parameters defined inside the `function()` parentheses. Actual arguments are the actual values passed when the function is called.
    356 
    357 </details>
    358 <br>
    359 
    360 <details>
    361 <summary><b>Q32: Can you change the order of arguments when calling a function?</b></summary>
    362 
    363 > Yes, by using named arguments (e.g., `power(b=3, a=2)`).
    364 
    365 </details>
    366 <br>
    367 
    368 <details>
    369 <summary><b>Q33: How do you give a parameter a default value?</b></summary>
    370 
    371 > By assigning it in the function definition: `my_func <- function(length = 5) { ... }`.
    372 
    373 </details>
    374 <br>
    375 
    376 <details>
    377 <summary><b>Q34: If an R function doesn't use the `return()` statement, what does it return?</b></summary>
    378 
    379 > It implicitly returns the result of the very last evaluated expression in the function body.
    380 
    381 </details>
    382 <br>
    383 
    384 <details>
    385 <summary><b>Q35: What is nested function calling?</b></summary>
    386 
    387 > Passing the result of one function directly as an argument into another function. E.g., `print(sum(1, 2))`.
    388 
    389 </details>
    390 <br>
    391 
    392 <details>
    393 <summary><b>Q36: What is 'Lazy Evaluation' in R?</b></summary>
    394 
    395 > R only evaluates function arguments when they are actually needed inside the function body.
    396 
    397 </details>
    398 <br>
    399 
    400 <details>
    401 <summary><b>Q37: If a function is defined as `f <- function(a, b) { print(a) }`, what happens if you call `f(5)` without providing `b`?</b></summary>
    402 
    403 > It successfully prints `5`. Because `b` is never used in the function, R's lazy evaluation ignores the missing argument.
    404 
    405 </details>
    406 <br>
    407 
    408 <details>
    409 <summary><b>Q38: Following the previous question, what happens if the function *does* use `b` later, e.g., `print(a + b)`?</b></summary>
    410 
    411 > R will throw an error only at the exact moment it tries to evaluate `b` and realizes it is missing.
    412 
    413 </details>
    414 <br>
    415 
    416 <details>
    417 <summary><b>Q39: What is an inline function?</b></summary>
    418 
    419 > A compact function written on a single line, often without braces. E.g., `f <- function(x) x^2`.
    420 
    421 </details>
    422 <br>
    423 
    424 <details>
    425 <summary><b>Q40: What is the output of `sum(4:6)`?</b></summary>
    426 
    427 > `15` (because 4 + 5 + 6 = 15).
    428 
    429 </details>
    430 <br>
    431 
    432 <details>
    433 <summary><b>Q41: What happens if you sum a vector containing an `NA`, like `sum(c(1, 2, NA))`?</b></summary>
    434 
    435 > The result is `NA`. You must use the argument `na.rm = TRUE` to ignore missing values.
    436 
    437 </details>
    438 <br>
    439 
    440 <details>
    441 <summary><b>Q42: What does `Inf` signify?</b></summary>
    442 
    443 > Positive Infinity, typically resulting from mathematical operations like dividing a positive number by 0.
    444 
    445 </details>
    446 <br>
    447 
    448 <details>
    449 <summary><b>Q43: What is the difference between `NaN` and `NA`?</b></summary>
    450 
    451 > `NaN` is 'Not a Number' (a mathematical impossibility like `0/0`). `NA` is a logical placeholder for missing data.
    452 
    453 </details>
    454 <br>
    455 
    456 <details>
    457 <summary><b>Q44: Is `NaN` considered an `NA`?</b></summary>
    458 
    459 > Yes, `is.na(NaN)` returns `TRUE`. However, `is.nan(NA)` returns `FALSE`.
    460 
    461 </details>
    462 <br>
    463 
    464 <details>
    465 <summary><b>Q45: If `x <- c(1, 2, 3)`, what does `str(x)` do?</b></summary>
    466 
    467 > It displays the compact internal structure of the object: `num [1:3] 1 2 3`.
    468 
    469 </details>
    470 <br>
    471 
    472 <details>
    473 <summary><b>Q46: What does `rm(x)` do?</b></summary>
    474 
    475 > It removes the variable `x` from the current workspace environment, freeing up memory.
    476 
    477 </details>
    478 <br>
    479 
    480 <details>
    481 <summary><b>Q47: How do you access the documentation/help file for the `sum` function?</b></summary>
    482 
    483 > Type `help(sum)` or `?sum` in the console.
    484 
    485 </details>
    486 <br>
    487 
    488 <details>
    489 <summary><b>Q48: How do you search for help regarding operators like `+` or reserved keywords like `if`?</b></summary>
    490 
    491 > You must wrap them in backticks or quotes: `help("+")` or `?"if"`.
    492 
    493 </details>
    494 <br>
    495 
    496 <details>
    497 <summary><b>Q49: What does `&` do vs `|` in R?</b></summary>
    498 
    499 > `&` is the logical AND operator (returns TRUE only if both sides are TRUE). `|` is the logical OR operator (returns TRUE if at least one side is TRUE).
    500 
    501 </details>
    502 <br>
    503 
    504 <details>
    505 <summary><b>Q50: What does the `!` operator do?</b></summary>
    506 
    507 > It is the logical NOT operator. It reverses booleans, turning `TRUE` to `FALSE` and vice versa.
    508 
    509 </details>
    510 <br>
    511 
    512 <details>
    513 <summary><b>Q51: What is the rule for starting a variable name with a period (.)?</b></summary>
    514 
    515 > A variable name can start with a period, but it CANNOT be followed immediately by a digit (e.g., `.myvar` is valid, `.2var` is invalid).
    516 
    517 </details>
    518 <br>
    519 
    520 <details>
    521 <summary><b>Q52: What is a Boolean shorthand in R?</b></summary>
    522 
    523 > You can type `T` or `F` instead of typing out `TRUE` or `FALSE`.
    524 
    525 </details>
    526 <br>
    527 
    528 <details>
    529 <summary><b>Q53: Are single characters (like "a") and strings (like "Word") considered different classes in R?</b></summary>
    530 
    531 > No, they both belong to the `character` class. R does not have a separate 'char' type like C or Java.
    532 
    533 </details>
    534 <br>
    535 
    536 <details>
    537 <summary><b>Q54: What does `%c`, `%e`, and `%u` do in the `sprintf()` function?</b></summary>
    538 
    539 > `%c` formats as a character, `%e` formats in scientific notation, and `%u` formats as an unsigned decimal integer.
    540 
    541 </details>
    542 <br>
    543 
    544 <details>
    545 <summary><b>Q55: What is a recursive function?</b></summary>
    546 
    547 > A function that calls itself from within its own code block (e.g., calculating a factorial mathematically).
    548 
    549 </details>
    550 <br>
    551 
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror