I have two .csv files. I need to match the 1st rows IDs in one file with the 1st column IDs in another file. im trying this-
If the first file contains a column named "ids" then i do this to extract the sample ids-
first_file_samples <- first_data_frame$ids
And for the second file, if all of the column names are ids-
second_file_samples <- colnames(second_data_frame)
then use this above function to extract sample ids for the second file. Then extract out the intersection between these vectors-
intersect_sample_ids <- intersect(first_file_samples, second_file_samples)
To filter out the first file, then-
subset_first_file <- first_data_frame %>% filter(ids %in% intersect_sample_ids)
subset_second_file <- second_data_frame %>% select(all_of(intersect_sample_ids))
But it does not seem to be working. Please tell me what could be going wrong?
Hi, can you include the first few lines from each of the files, and an example of the desired output? The easiest way to share the data would be the output of
dput(head(first_file_samples))
as an example for the first file.