MGSC 291 EXAM 1 QUESTIONS & ANSWERS
R code: + - Answers -addition
R code: - - Answers -subtraction
R code: * - Answers -multiplication
R code: / - Answers -division
R code: ^ - Answers -exponent
R code: # - Answers -note (anything after this symbol will be ignored by R)
R code: <- - Answers -defines an object
R code: c - Answers -combine function (creates a vector of numbers. numbers can
either be separated by commas, or by a colon (1,2,3,4) or 1:4)
R code: seq() - Answers -sequence function (creates a vector with the sequence (from,
to, by) ex: seq(1,10,0.1) creates a vector from one to 10 counting by 0.1)
R code: help(functionName) - Answers -help function (opens a web browser to display
a help file)
R code: NA - Answers -missing value
R code: mean () - Answers -average
R code: na.rm=T - Answers -removes all missing values (from the given data set. in R
all missing values are labeled as NA)
R code: sqrt() - Answers -square root
R code: log() - Answers -natural logarithm
R code: exp(a) - Answers -e^a
R code: sd() - Answers -sample standard deviation
R code: var() - Answers -sample variance
R code: length() - Answers -length of vector (including NAs)
, R code: dim() - Answers -dimension of data frame - rows, columns
R code: factor(x) - Answers -makes R recognize x as categorical
R code: cbind() - Answers -bind (combine) objects by columns
R code: rbind() - Answers -bind objects by rows
R code: sort() - Answers -sort from smallest to largest
R code: order() - Answers -sort a data frame based on specified columns(s)
R code: round(x,a) - Answers -round x to a decimal places
R code: rep(x,n) - Answers -repeat x n times
R code: which() - Answers -returns the position number where argument is true
R code: ifelse(cond,a,b) - Answers -if condition is met, return a, otherwise return b
R code: sample() - Answers -sample from a dataset
R code: paste() - Answers -concatenate text
R code: object() or ls() - Answers -returns a list of all stored objects
R code: == - Answers -equal to
R code: != - Answers -not equal to
R code: < - Answers -less than
R code: <= - Answers -less than or equal to
R code: > - Answers -greater than
R code: >= - Answers -greater than or equal to
R code: | - Answers -or
R code: & - Answers -and
R code: a%in%b - Answers -is "a" contained in "b"
R code: %*% - Answers -matrix multiplication
R code: + - Answers -addition
R code: - - Answers -subtraction
R code: * - Answers -multiplication
R code: / - Answers -division
R code: ^ - Answers -exponent
R code: # - Answers -note (anything after this symbol will be ignored by R)
R code: <- - Answers -defines an object
R code: c - Answers -combine function (creates a vector of numbers. numbers can
either be separated by commas, or by a colon (1,2,3,4) or 1:4)
R code: seq() - Answers -sequence function (creates a vector with the sequence (from,
to, by) ex: seq(1,10,0.1) creates a vector from one to 10 counting by 0.1)
R code: help(functionName) - Answers -help function (opens a web browser to display
a help file)
R code: NA - Answers -missing value
R code: mean () - Answers -average
R code: na.rm=T - Answers -removes all missing values (from the given data set. in R
all missing values are labeled as NA)
R code: sqrt() - Answers -square root
R code: log() - Answers -natural logarithm
R code: exp(a) - Answers -e^a
R code: sd() - Answers -sample standard deviation
R code: var() - Answers -sample variance
R code: length() - Answers -length of vector (including NAs)
, R code: dim() - Answers -dimension of data frame - rows, columns
R code: factor(x) - Answers -makes R recognize x as categorical
R code: cbind() - Answers -bind (combine) objects by columns
R code: rbind() - Answers -bind objects by rows
R code: sort() - Answers -sort from smallest to largest
R code: order() - Answers -sort a data frame based on specified columns(s)
R code: round(x,a) - Answers -round x to a decimal places
R code: rep(x,n) - Answers -repeat x n times
R code: which() - Answers -returns the position number where argument is true
R code: ifelse(cond,a,b) - Answers -if condition is met, return a, otherwise return b
R code: sample() - Answers -sample from a dataset
R code: paste() - Answers -concatenate text
R code: object() or ls() - Answers -returns a list of all stored objects
R code: == - Answers -equal to
R code: != - Answers -not equal to
R code: < - Answers -less than
R code: <= - Answers -less than or equal to
R code: > - Answers -greater than
R code: >= - Answers -greater than or equal to
R code: | - Answers -or
R code: & - Answers -and
R code: a%in%b - Answers -is "a" contained in "b"
R code: %*% - Answers -matrix multiplication