Can someone help me with figuring out where i am making a mistake with my code. I want to filter data in one dataframe by matching value of its column with the value of another column one by one. And then calculate the proportion of the filtered data based on 1 and 0 in another column of the filtered data. But I am getting iterations for all obersations again and again and am getting only the same proportion everytime. My code is:
its hard to start to reason about your code ...
i and j are looping variables, and you compare them directly inside a filter on a dataset ?
so you will either get all rows or no rows from your dataset based on whether i is smalled than j or not.
In order for your code to be reproducible, you would have to supply all the values necessary to run your code and reproduce the issue. Namely, the lengths of u2 and u, and the contents of df, which you can share by running dput(df), and the posting the output here, between a pair of triple backticks, like this:
I want to compare u2 with u (in df). Take u2 one by one and filter data in df with u>=u2 to compute proportions based on binary response in the group column of df.
Any help will be appreciated! Thanks!