I have list of samples as a txt file and want to only keep these samples from this large file; column name is samples name in the large file.
library(readr)
library(data.table)
df1 <- read_csv("control.csv", col_types = cols(Chromosome = col_skip(), Start = col_skip(), End = col_skip(), Strand = col_skip()))
df1[1:5,1:5]
# A tibble: 5 × 5
ID DN54 DC146 DDN44 DC179
<chr> <dbl> <dbl> <dbl> <dbl>
1 cg26928153 0.848 0.879 0.872 0.897
2 cg16269199 0.731 0.732 0.759 0.775
3 cg13869341 0.842 0.863 0.819 0.896
4 cg24669183 0.824 0.866 0.822 0.910
5 cg26679879 0.425 0.363 0.420 0.358