Description Usage Arguments Details Examples
This function is to attach textual label to numeric data by using a code spec
1 |
data |
dataframe |
code_spec |
dataframe with 3 columns: first one being "varible name", second one being "code", and thrid one being "label" |
This function would show output covering 3 cases: 1) The variable being processed is not included in code spec, in which case the variable would be left unchanged; 2) The variable being processed is a SA question, and 3) The variable being process is a MA question
Note that if the code is not specified in code spec, the cell containing that code would be showing NA, rather than displaying its original code
Use xlsx::write.xlsx() to export, with the argument showNA being set as FALSE.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | data <- data.frame(vQ1=c(1, 3, 4, 99),
vQ2=c("1,2", "3,4", "5,3", "1,2,99"),
vQ3=c(NA, NA, NA, NA),
vQ4=c(NA, 1, 3, "2,4"),
vQ5=c(1,2,3,4), stringsAsFactors=FALSE)##Populate the "data" dataframe
code_spec <- data.frame(variable_name=rep(c("vQ1", "vQ2", "vQ3", "vQ4"), each=5),
code=rep(c(1,2,3,4,5), times=4),
label=rep(c("1. Ricoh",
"2. Fuji Xerox",
"3. Canon",
"4. Konica Minolta",
"5. Sharp"), times=4))##Populate the "code_spec" dataframe
labelling(data, code_spec)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.