Data Creation Flashcards Preview

R > Data Creation > Flashcards

Flashcards in Data Creation Deck (14)
Loading flashcards...
1

c(...)

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

2

from:to

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

3

seq(from,to)

generates a sequence by= specifies increment; length=
specifies desired length

4

seq(along=x)

generates 1, 2, ..., length(along); useful for for
loops

5

rep(x,times)

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

6

data.frame(...)

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

7

list(...)

create a list of the named or unnamed arguments;
list(a=c(1,2),b="hi",c=3i);

8

array(x,dim=)

array with data x; specify dimensions like
dim=c(3,4,2); elements of x recycle if x is not long enough

9

matrix(x,nrow=,ncol=)

matrix; elements of x recycle

10

factor(x,levels=)

encodes a vector x as a factor

11

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

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

12

expand.grid()

a data frame from all combinations of the supplied vec-
tors or factors

13

rbind(...)

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

14

cbind(...)

id. by columns