Help conditional length function

Hey! So I've been struggling on how to count the number of entries in this data frame.

zee = rep(1, 2000)
CI_5 = data.frame(upper_90 -> x1, lower_90 -> y1, zee -> z1)
length(CI_5$z1....zee[x1 <= 1 & y1 >= 1])

I want to count the row if x1 <= 1 and y1 >= 1 but I keep getting 0 even though i see some entries where this is true in the data frame. Any advice?

Hi, and welcome.

Please review the FAQ: What's a reproducible example (`reprex`) and how do I do one? This leads to better answers.

Using dplyr on a data frame, to get the count of rows meeting some condition, the filter() function piped to count() will get you a summary like this

(mtcars %>% filter(mpg <= 25 & wt >= 3.500) %>% count())
#> # A tibble: 1 x 1
#>       n
#>   <int>
#> 1    11

Created on 2020-02-24 by the reprex package (v0.3.0)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.