r - Conditionally replace values with NA as they appear in another data frame -
sorry tried posting first time posting here. relatively new r , have issue 2 data frames need address. based on 2 sets of date/time meteorological data need compare, first need make values na appear in first df.
df1 <- data.frame(wspeed=c(5,3,6,7), wdirection=c(150,160,30,40), rain=c(na,na,3,10), rh=c(na,15,90,na)) df2 <- data.frame(wspeed=c(10,5,2,8), wdirection=c(160,150,40,25), rain=c(5,10,3,10), rh=c(20,15,90,50))
to give me
df1 wspeed wdirection rain rh 1 5 150 na na 2 3 160 na 15 3 6 30 3 90 4 7 40 10 na df2 wspeed wdirection rain rh 1 10 160 5 20 2 5 150 10 15 3 2 40 3 90 4 8 25 10 50
i need df2 resemble this:
wspeed wdirection rain rh 1 10 160 na na 2 5 150 na 15 3 2 40 3 90 4 8 25 10 na
i have date/time column in each row. have searched , can't find answer , hoping if relatively simple answer.
thanking in advance!
Comments
Post a Comment