Week 2 from Quizlet Flashcards

(46 cards)

1
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

control structures in R allow you to…

A

control the flow of execution of the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

if, else

A

testing a condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

for

A

execute a loop a fixed number of times

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

while

A

executes a loop while a condition is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

repeat

A

execute an infinite loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

break

A

break the execution of a loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

next

A

skip an interaction of a loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

return

A

exit a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a loop index shown as

A

i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

loop index

A

A counter variable used in For / Next loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

seq_len()

A

Generate regular sequences. and the length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

seq_along()

A

Generate regular sequences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

subset()

A

Return subsets of vectors, matrices or data frames which meet conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to stop an infinite loop

A

break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

how to skip a part of a loop

A

next

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How to tell R to exit a function and return a given value

A

return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what function do you use to construct a function?

A

function()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what do you use to get a standard deviation?

20
Q

what does na.rm do?

A

removes NA’s from the object working on

21
Q

how to remove NA’s and calculate the sd of a mydata file

A

sd(na.rm=TRUE, mydata)

22
Q

What arguments are commonly specified when you call lm()

A

file, formula, subset,model.

lm(y-x, mydata, 1:100, model=FALSE)

23
Q

what does NULL mean?

A

There’s nothing there

24
Q

what is the “…” argument?

A

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.

25
Where should you write functions?
in a text file, by choosing "r script" in R
26
How wide should your code be maximum
80 columns of text
27
How to Return subsets of vectors, matrices or data frames which meet conditions.
subset()
28
What is an environment?
a collection of (symbol, value) pairs, i.e x is a symbol and 3.14 might be its value
29
a function + an enviroment =
a closure or function closure
30
what is the global environment
the workspace
31
what is an empty environment
an environment without a parent
32
What does Lexical Scoping mean?
the values of free variables are searched for in the environment in which the function was defined
33
free variable
variables used in a function that are not local variables nor parameters of that function.
34
How to look at the arguments of a function
ls(environment(function name))
35
How to get the value of an argument in a function, ie n
get("n", environment(function name))
36
what class represents the date
Date class
37
what classes represent times
POSIXct class and POSIXlt class
38
how to convert date into a string
as.Date("yr mnth day")
39
How to get current time
Sys.time()
40
what function do you use to format how date/time are printed?
strptime()
41
What is an environment in R?
a collection of symbol/value pairs
42
The R language uses what type of scoping rule for resolving free variables?
lexical scoping
43
How are free variables in R functions resolved?
The values of free variables are searched for in the environment in which the function was defined
44
What is one of the consequences of the scoping rules used in R?
All objects must be stored in memory
45
In R, what is the parent frame?
It is the environment in which a function was called
46