Converting Input data with different coding scheme to standard format

Share:

Description

Converting Input data with different coding scheme to standard format

Usage

1
ConvertData(input, yesLabel = NULL, noLabel = NULL, missLabel = NULL)

Arguments

input

matrix input, the first column is ID, the rest of the columns each represent one symptom

yesLabel

The value(s) coding "Yes" in the input matrix.

noLabel

The value(s) coding "No" in the input matrix.

missLabel

The value(s) coding "Missing" in the input matrix.

Value

a matrix with coding scheme as follows: "Y" for yes, "" for No, and "." for missing.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# make up a fake 2 by 3 dataset with 2 deaths and 3 symptoms
id <- c("d1", "d2")
x <- matrix(c("Yes", "No", "Don't know",
			  "Yes", "Refused to answer", "No"),
			byrow = TRUE, nrow = 2, ncol = 3)
x <- cbind(id, x)
colnames(x) <- c("ID", "S1", "S2", "S3")
# see possible raw data (or existing data created for other purpose)
x
new <- ConvertData(x, yesLabel = "Yes", noLabel = "No",
			missLabel = c("Don't know", "Refused to answer"))
new