generateRandomNAs: add random NAs to a data.frame

Description Usage Arguments Value Author(s) Examples

Description

add random NAs to a data.frame

Usage

1
  generateRandomNAs(df, protected, numberOfNAs, seed)

Arguments

df

input

protected

are cols of the data.frames which need to be proteced from random NAs

number

of NAs that should be introduced.

seed

for reproducible random number generation

Value

data.frame that contains several random NAs within its questions

Author(s)

Matthias Bannert

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# generate survey likerandom sample
srvyData <- generateSamplePanel(500,3,"quarterly",
                                c(1999,1),
                                c(1999,1),
                                weight=round(runif(500,2,80)))


# generate 
grps <- generateRandomGroups(3,1:500,LETTERS)

# merge group information by uid
srvyWgroups <- merge(grps,srvyData,by="uid")

# add some NAs (to simulate item non-response)
# check which cols should be protected from 
# being hit by random NAs
head(srvyWgroups)
randomPanel <- generateRandomNAs(srvyWgroups,c(1,2,3,4),50,1)
randomPanel

mbannert/gateveys documentation built on May 21, 2019, 2:23 p.m.