0

Forum,

I am an R-noob and have a problem with which you can possibly help me. It concerns 2 dfs (df1 = 38 columns, df2 = 49 columns), which I have attached in form of a of 2 pic. In each of the 2 df`s there is a time specification (df1= 2nd column ,df2 = 13th column), the remaining columns consist of doubles with values >= 0. Each column of df1 belongs to a column of df2 (correspond to identical designation). I want R to go to the 3rd column (MT_19_2) of df1 and see if there is a value > 0. If yes, the script should remember the corresponding time and look in df2 if there is a value > 0 in the corresponding 14th column (also called MT_19_2) in a time window of +.-01 min. If yes, the complete row of df2 is to be noted in a new df3. If there are several values in the time window, only the closest one should be selected. After that, the script should check the lines below df1 to see if there is a value > 0 and do the same comparison again. The values already assigned from df2 should not be available for this comparison.

I hope you understand what I mean and can help me! Hera are 2 pics of the df1 and df2:

enter image description here enter image description here

The 3. df should look like:

enter image description here

Best wishes,

Locardas

  • 1
    Please don’t use images of data as they cannot be used without a lot of unnecessary effort. [For multiple reasons](//meta.stackoverflow.com/q/285551) Questions should be reproducible. Check out stack overflow guidance [mre] and [ask]. Include a minimal dataset in the form of an object for example if a data frame as `df <- data.frame(…)` where … are your variables and values or use `dput(head(df))`. [Good overview on asking questions](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Peter Jan 29 '22 at 13:22
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 03 '22 at 10:17

0 Answers0