What are R's primary data types?
Numeric, integer, character, logical, and complex.
How does R represent numbers by default, and what marks an integer explicitly?
Numbers default to double-precision numeric values; the L suffix marks an integer, as in 42L.
What may begin an R variable name?
A letter or a dot not immediately followed by a number.
Which characters may appear later in an R variable name?
Letters, numbers, dots, or underscores.
What characters are prohibited in R variable names?
Spaces and special characters.
Which kinds of words should not be used as R variable names?
Reserved words such as if, else, TRUE, FALSE, NULL, for, or function.
Which R data structures hold elements of the same type?
Vectors and matrices.
What is a vector?
An ordered collection of elements of the same type.
What values does `c(2, 6, 1, 3, 11)` create?
2, 6, 1, 3, and 11.
What is a factor in R?
A vector representing a categorical variable whose labels have underlying numeric codes.
What is an ordered factor?
A categorical factor whose levels have a specified order.
Which prefixes identify R density, cumulative probability, quantile, and random-generation functions?
The prefixes are dxxx, pxxx, qxxx, and rxxx, respectively.
What does `set.seed(number)` set for subsequent pseudo-random generation?
The random seed.
How are character values represented in R?
As text enclosed in single or double quotes.
Which case-sensitive values represent logical data in R?
TRUE and FALSE.
What parts do complex values contain in R?
Real and imaginary parts.
Which symbol denotes the imaginary part in R complex values?
The symbol i, as in 3 + 4i.
What do R's is.xxxx functions do?
They check a data type.
What do R's as.xxxx functions do?
They transform a value's type.
How does R treat variable names that differ only in capitalization?
As different names.
Which listed name is a valid R variable name: myVariable, data.frame, .hiddenVar, or var_123?
All four are valid R variable names.
Which listed names are invalid R variable names: 1stVar, my-var, or NULL?
All three are invalid R variable names.
What does the R function `t()` do to a vector or matrix?
It transposes it.
How does `t(v)` display `v <- c(2, 6, 1, 3, 11)`?
As a row.
What values does `seq(from=-4, to=5, by=1.5)` generate?
-4.0, -2.5, -1.0, 0.5, 2.0, 3.5, and 5.0.
What step size does `seq(from=-4, to=5)` use when `by` is omitted?
1.
What does `rep(2, 5)` return?
The value 2 repeated five times.
What does R's factor() function do to a character vector of categories?
It converts the vector into a factor with category levels.
What levels does factor(gender) have for the given male-and-female gender vector?
Female and male.
What order does ordered(edu, levels=c("h", "u", "p")) assign?
Which distribution families are included in the R handout?
Beta, binomial (including Bernoulli), Cauchy, chi-squared, exponential, F, gamma, geometric, hypergeometric, log-normal, multinomial, negative binomial, normal, Poisson, Student's t, uniform, and Weibull.
What does `rnorm(1)` generate by default?
One random value from the standard normal distribution.
What does `rnorm(n=31, mean=14, sd=2)` generate?
31 random values from a normal distribution with mean 14 and standard deviation 2.
What does `round(runif(1, min=1, max=6), 0)` produce?
A random integer obtained by rounding a uniform value between 1 and 6.
What can the random package generate?
Integers, random sequences, and random strings.
What values does `seq(4, 5, length.out=5)` generate?
4.00, 4.25, 4.50, 4.75, and 5.00.
What labels can the labels argument assign to ordered levels h, u, and p, respectively?
High school, undergraduate, and postgraduate.
What must be supplied to an R distribution function?
Parameters appropriate to that distribution.
Answer 11 questions on R Variables Vectors and Random Numbers.
1. In R, what type is assigned to each value in `a <- 42` and `b <- 42L`, respectively?
2. Which set lists R’s five primary data types?
Go over the full study guide for R Variables Vectors and Random Numbers.
Read the study guide →Upload your class notes and Revizly writes your flashcards in about a minute.
Flashcard maker