jeudi 26 novembre 2015

subseting a df based on conditions in another one

I have two dfs, both dim [1] 54 210. One (lets call it dfx) contains 1, 0s to mark incorrect and correct answers on a test. dfy contains the response time for each of these questions. I'd like to subset(merge() (perhaps) all items from dfy that are == 1 in dfx. The data is in the wide format, ID = rownames and columns represent each question.

I tried test<- subset(merge(dfx, dfy)[dfx == 1]) however it doesn't work and I am not sure how to use the ifelse function with two dataframes in a way that it keeps the original value from dfy if dfx == 1.

I perhaps made it more complicated then it is... however I'd appreciate your help :)

Aucun commentaire:

Enregistrer un commentaire