Possible duplicate: Extracting specific columns from a data frame
I have a data frame that follows a pattern in the columns. Here I have some 10 columns but actually in the final data frame the number of columns is not know as it depends on the data given.
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
ADAM32 P 0.001000000 40.61038 P 0.001000000 40.61038 P 0.001000000 40.61038
CCL5 P 0.000491000 6546.20000 P 0.000491000 6546.20000 P 0.000491000 6546.20000
CILP2 A 0.500000024 92.66398 A 0.500000024 92.66398 A 0.500000024 92.66398
EPHB3 P 0.000562000 461.30000 P 0.000562000 461.30000 P 0.000562000 461.30000
GUCA1A P 0.002006000 9.40000 P 0.002006000 9.40000 P 0.002006000 9.40000
HSPA6 P 0.000322000 564.00000 P 0.000322000 564.00000 P 0.000322000 564.00000
MAPK1 P 0.002000000 435.00000 P 0.002000000 435.00000 P 0.002000000 435.00000
PIGX P 0.003822926 411.38856 P 0.003822926 411.38856 P 0.003822926 411.38856
PTPN21 M 0.051040220 94.30000 M 0.051040220 94.30000 M 0.051040220 94.30000
THRA M 0.054470000 151.10000 M 0.054470000 151.10000 M 0.054470000 151.10000
UBA7 P 0.000468000 845.60000 P 0.000468000 845.60000 P 0.000468000 845.60000
WFDC2 P 0.005475547 177.61689 P 0.005475547 177.61689 P 0.005475547 177.61689
7-Mar P 0.000673000 643.20000 P 0.000673000 643.20000 P 0.000673000 643.20000
In the above data frame I want the first two columns and then column after two columns, column after two columns and so on in the same fashion. Therefore I want v1,v2,v5,v8 and so on till the data frame is exhausted. So if I have a data frame of 1000 columns in the same pattern, how can I select the columns?
The expected output:
V1 V2 V5 V8
ADAM32 P P P
CCL5 P P P
CILP2 A A A
EPHB3 P P P
GUCA1A P P P
HSPA6 P P P
MAPK1 P P P
PIGX P P P
PTPN21 M M M
THRA M M M
UBA7 P P P
WFDC2 P P P
7-Mar P P P