r - Match entire columns between two dataframes -


i have 2 dataframes

y <- data.frame(y1=seq(1:5), y2=letters[seq(1:5)]) x <- data.frame(x1=seq(1:5)*3,x2=seq(1:5), x3=letters[5:9], x4=letters[1:5]) 

and wat extract columns

x

that entirely match

y

columns.

does have clue?

thank you

we can loop , comparison

x[sapply(y, function(.y) which(colsums(x== as.character(.y))== nrow(y)))] 

or option is

i1 <- sapply(x, paste, collapse=",") %in% sapply(y, paste, collapse=",") i1 #[1] false  true false  true x[i1] 

Comments

Popular posts from this blog

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

javascript - Create a stacked percentage column -