Sample data frame:
df<-as.data.frame(matrix(sample(1:10,100,replace=TRUE),10))
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1 8 9 3 2 4 5 8 8 6 5
2 2 4 5 7 4 6 6 2 4 3
3 1 5 4 10 8 10 10 3 5 2
4 10 7 10 7 2 8 2 3 8 10
5 1 7 4 5 1 3 3 2 1 4
6 4 7 3 4 5 4 1 2 4 5
7 10 10 7 9 5 10 3 10 7 1
8 7 5 2 2 5 6 10 10 4 6
9 3 2 10 2 4 8 3 2 9 7
10 8 6 6 9 9 4 8 10 3 6
Now if I want V2 and V4 ?
data.frame(df$V2,df$V4)
But I want more accurate and compact way!