You can just select the columns with, for instance, a<-dat[,(dat[1,]) == 1]
; the only trick is re-setting the column names when you end up extracting a single column.
datatxt <- "
NE001457 NE001458 NE001494 NE001532 NE001533 NE001542
1 0 1 1 1 1
0.22951556 0.39403959 0.11835655 0.40844591 0.28442078 0.24236144
0.04566349 0.14491037 0.03184582 0.0819644 0.18298301 -0.0339111
0.04543686 0.05876655 0.23562874 -0.0717529 -0.0320517 -0.0851137"
df <- read.table(text=datatxt,header=TRUE)
df
# NE001457 NE001458 NE001494 NE001532 NE001533 NE001542
#1 1.00000000 0.00000000 1.00000000 1.0000000 1.0000000 1.0000000
#2 0.22951556 0.39403959 0.11835655 0.4084459 0.2844208 0.2423614
#3 0.04566349 0.14491037 0.03184582 0.0819644 0.1829830 -0.0339111
#4 0.04543686 0.05876655 0.23562874 -0.0717529 -0.0320517 -0.0851137
acols <- (df[1,] == 1)
bcols <- !acols
acols
# NE001457 NE001458 NE001494 NE001532 NE001533 NE001542
#1 TRUE FALSE TRUE TRUE TRUE TRUE
bcols
# NE001457 NE001458 NE001494 NE001532 NE001533 NE001542
#1 FALSE TRUE FALSE FALSE FALSE FALSE
a <- as.data.frame(df[,acols])
colnames(a) <- colnames(df)[acols]
b <- as.data.frame(df[,bcols])
colnames(b) <- colnames(df)[bcols]
a
# NE001457 NE001494 NE001532 NE001533 NE001542
#1 1.00000000 1.00000000 1.0000000 1.0000000 1.0000000
#2 0.22951556 0.11835655 0.4084459 0.2844208 0.2423614
#3 0.04566349 0.03184582 0.0819644 0.1829830 -0.0339111
#4 0.04543686 0.23562874 -0.0717529 -0.0320517 -0.0851137
b
# NE001458
#1 0.00000000
#2 0.39403959
#3 0.14491037
#4 0.05876655