Check if information between two data.frames are identical

Hi Fellows.
I need a help with the following issue:

I have two txt files as data.frames, and I need to check if the first row in "AE" is identifical to the first column in "AP". If it is, than keep executing the code until finish. If it is not, than stop code.

So it would be necessary transpose the first row into column and compare them. Can you help me with it?

Code to importo data.frame
AE <-"File1", h = F, sep = "\t"))
AP <-"File2", h = F, sep = "\t"))

Here's how I'd do it.


# define data
D1 <- data.frame(A = c(1, 2, 3, 4), B = c(4, 5, 6, 7))
D2 <- data.frame(C = c(1, 4), D = c(2, 5), E = c(9, 9), F = c(9, 9))

# check each row
Check <- map2_lgl(
    D1 %>% as.matrix() %>% split(1:nrow(.)),
    D2 %>% as.matrix() %>% t() %>% split(1:nrow(.)),

# vector of whether each row is identical
#>     1     2     3     4 

# number of identical rows
#> [1] 2

Created on 2021-05-31 by the reprex package (v1.0.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.