Week 2 from Quizlet Flashcards

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?

A

sd()

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
Q

Where should you write functions?

A

in a text file, by choosing “r script” in R

26
Q

How wide should your code be maximum

A

80 columns of text

27
Q

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

A

subset()

28
Q

What is an environment?

A

a collection of (symbol, value) pairs,

i.e x is a symbol and 3.14 might be its value

29
Q

a function + an enviroment =

A

a closure or function closure

30
Q

what is the global environment

A

the workspace

31
Q

what is an empty environment

A

an environment without a parent

32
Q

What does Lexical Scoping mean?

A

the values of free variables are searched for in the environment in which the function was defined

33
Q

free variable

A

variables used in a function that are not local variables nor parameters of that function.

34
Q

How to look at the arguments of a function

A

ls(environment(function name))

35
Q

How to get the value of an argument in a function, ie n

A

get(“n”, environment(function name))

36
Q

what class represents the date

A

Date class

37
Q

what classes represent times

A

POSIXct class and POSIXlt class

38
Q

how to convert date into a string

A

as.Date(“yr mnth day”)

39
Q

How to get current time

A

Sys.time()

40
Q

what function do you use to format how date/time are printed?

A

strptime()

41
Q

What is an environment in R?

A

a collection of symbol/value pairs

42
Q

The R language uses what type of scoping rule for resolving free variables?

A

lexical scoping

43
Q

How are free variables in R functions resolved?

A

The values of free variables are searched for in the environment in which the function was defined

44
Q

What is one of the consequences of the scoping rules used in R?

A

All objects must be stored in memory

45
Q

In R, what is the parent frame?

A

It is the environment in which a function was called

46
Q
A