Data Creation Flashcards

1
Q

c(…)

A

generic function to combine arguments with the default forming a vector; with recursive=TRUE descends through lists combining all elements into one vector

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

from:to

A

generates a sequence; “:” has operator priority; 1:4 + 1 is “2,3,4,5”

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

seq(from,to)

A

generates a sequence by= specifies increment; length=

specifies desired length

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

seq(along=x)

A

generates 1, 2, …, length(along); useful for for

loops

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

rep(x,times)

A

replicate x times; use each= to repeat “each” el-
ement of x each times; rep(c(1,2,3),2) is 1 2 3 1 2 3;
rep(c(1,2,3),each=2) is 1 1 2 2 3 3

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

data.frame(…)

A

create a data frame of the named or unnamed
arguments; data.frame(v=1:4,ch=c(“a”,”B”,”c”,”d”),n=10);
shorter vectors are recycled to the length of the longest

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

list(…)

A

create a list of the named or unnamed arguments;

list(a=c(1,2),b=”hi”,c=3i);

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

array(x,dim=)

A

array with data x; specify dimensions like

dim=c(3,4,2); elements of x recycle if x is not long enough

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

matrix(x,nrow=,ncol=)

A

matrix; elements of x recycle

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

factor(x,levels=)

A

encodes a vector x as a factor

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

gl(n,k,length=n*k,labels=1:n)

A

generate levels (factors) by spec-
ifying the pattern of their levels; k is the number of levels, and n is
the number of replications

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

expand.grid()

A

a data frame from all combinations of the supplied vec-

tors or factors

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

rbind(…)

A

ombine arguments by rows for matrices, data frames, and others

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

cbind(…)

A

id. by columns

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