-1

I have merged health data (cases) with population data. In some instances, the number of cases (n) is greater than the population size (N). I will need to drop these rows.

What is the most efficient way to do this in R? For example: where n > N, replace n with 0?

enat_b
  • 28
  • 4

1 Answers1

0

To drop rows

df = df[df$n < df$N,]

for replacement

df[df$n > df$N,"n"] = 0

DDV
  • 16