I have created a data frame using the following code:
manager <- c(1,2,3,4,5) date <- c("10/24/08","10/28/08","10/1/08","10/12/08","5/1/09") country <- c("US","US","UK","UK","UK") gender <- c("M","F","F","M","F") age <- c(32,45,25,39,99) q1 <- c(5,3,3,3,2) q2 <- c(4,5,5,3,2) q3 <- c(5,2,5,3,2) q4 <- c(5,5,5,NA,2) q5 <- c(5,5,2,NA,1) leadership <- data.frame(manager,date,country,gender,age, q1,q2,q3,q4,q5, stringsAsFactors = FALSE) I have then queried using the following: View(leadership[c(1:3),c("q1","q2","q3","q4","q5")])
My question is as follows: Is there any way to set up an ordered structure to the columns, such that I will be able to query using the following code? View(leadership[c(1:3),c("q1":"q5")])
Thanks in advance.