mvvar | R Documentation |
Function to move a variable to a different position in a data frame.
mvvar(var, where, after=TRUE, data)
var |
variable to move. |
where |
variable next to which |
after |
logical indicating whether to position |
data |
data frame that contains the variables specified above. |
The function can be used to move a variable to a different position in a data frame.
A data frame.
Wolfgang Viechtbauer wvb@wvbauer.com
# illustrative dataset
dat <- data.frame(subj=rep(1:4, each=5),
obs = 1:5,
age = rep(c(20,31,27,22), each=5),
stress = c(2,3,1,4,2, 3,3,3,3,3, 1,1,2,6,4, 1,2,1,3,1))
dat
# move variable age after subj
dat <- mvvar("age", "subj", data=dat)
dat
# move variable obs before age
dat <- mvvar("obs", "age", after=FALSE, data=dat)
dat
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.