Hi,
Try:
set.seed(24)
dat1<- as.data.frame(matrix(sample(1:60,15*5,replace=TRUE),ncol=15))
colnames(dat1)<- paste0("a",c(3,1,5,7,2,8,11,14:15,10,9,6,12:13,4))
?subDat1<-dat1[colnames(dat1)[as.numeric(gsub("[A-Za-z]","",colnames(dat1)))<=10]]
?subDat1
#? a3 a1 a5 a7 a2 a8 a10 a9 a6 a4
#1 18 56 37 55? 6 42?? 5 28 60? 9
#2 14 17 23 12 34? 5? 24 52 28 13
#3 43 46 41? 3 44 36? 22 28 18? 1
#4 32 49 41 31? 9 38? 16 43 11 60
#5 40 16 20? 9 14? 3? 21 33? 9 39
A.K.
>Hi,
>? ? I have one data set with 15 variable like a3, a1, a5, a7,a2, a8,
a11, a14, a15, a10, a9, a6, a12, a13, a4. From this variable i want to
select >variables from a1:a10. Please helpe to to get the result..