Week 2 from Quizlet Flashcards
(46 cards)
control structures in R allow you to…
control the flow of execution of the program
if, else
testing a condition
for
execute a loop a fixed number of times
while
executes a loop while a condition is true
repeat
execute an infinite loop
break
break the execution of a loop
next
skip an interaction of a loop
return
exit a function
What is a loop index shown as
i
loop index
A counter variable used in For / Next loop.
seq_len()
Generate regular sequences. and the length
seq_along()
Generate regular sequences.
subset()
Return subsets of vectors, matrices or data frames which meet conditions.
How to stop an infinite loop
break
how to skip a part of a loop
next
How to tell R to exit a function and return a given value
return
what function do you use to construct a function?
function()
what do you use to get a standard deviation?
sd()
what does na.rm do?
removes NA’s from the object working on
how to remove NA’s and calculate the sd of a mydata file
sd(na.rm=TRUE, mydata)
What arguments are commonly specified when you call lm()
file, formula, subset,model.
lm(y-x, mydata, 1:100, model=FALSE)
what does NULL mean?
There’s nothing there
what is the “…” argument?
it indicates a variable number of arguments that are usually passed on to other functions. Often used when extending a function or if arguments can’t be known in advance.