View source: R/dthelper-collapse-recode-variables.R View source: R/dthelper-collapse-column.R
recode.multiple | R Documentation |
Recodes variables that share the same scale
recode.multiple(df, var, from, to = 1:length(from), fun = as.numeric)
df |
data.frame object |
var |
Variable to recode |
from |
Original scale (order of input needs to match desired scale) |
to |
Desired scale (order of input needs to match original scale). Defaults to integer scale starting from 1 |
fun |
Function determining object type of output variables |
data.frame object
df <- data.frame( v1 = c("Strongly Disagree","Disagree", "Neutral"," Agree", "Strongly Agree"), v2 = c("Strongly Disagree","Disagree","Strongly Disagree","Disagree","Strongly Disagree"), v3 = c( "Neutral"," Agree", "Strongly Agree", "Neutral"," Agree") ) recode.multiple(df, var = c("v1","v2","v3"), from = c("Strongly Disagree","Disagree", "Neutral"," Agree", "Strongly Agree")) recode.multiple(df, var = c("v1","v2","v3"), from = c("Strongly Disagree","Disagree", "Neutral"," Agree", "Strongly Agree"), to = c(10,20,30,40,50)) recode.multiple(df, var = c("v1","v2","v3"), from = c("Strongly Disagree","Disagree", "Neutral"," Agree", "Strongly Agree"), to = c("ten", "twenty", "thirty", "forty", "fifty"), fun = function(x){factor(x, levels = c("ten", "twenty", "thirty", "forty", "fifty"))})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.