0

I want to filter out all the row_number >12 from a data frame like this:

 head(dat1)
# A tibble: 6 × 7
  date       order_id       product_id   row_number shelf_number shelf_level position
  <date>     <chr>          <chr>             <dbl> <chr>        <chr>          <dbl>
1 2020-01-02 ES100025694747 000072489501          6 01           C                 51
2 2020-01-02 ES100025694747 000058155401          2 39           B                 51
3 2020-01-02 ES100025694747 000067694201         21 28           B                 51
4 2020-01-02 ES100025699052 000057235001          9 05           B                 31
5 2020-01-02 ES100025699052 000050456101          5 29           D                 31
6 2020-01-02 ES100025699052 000067091601          2 17           D                 11

The row_number orginally contains values like this:

dat1 %>% distinct(row_number)
# A tibble: 15 × 1
   row_number
        <dbl>
 1          6
 2          2
 3         21
 4          9
 5          5
 6          1
 7         10
 8          3
 9          4
10          8
11          7
12         20
13         22
14         11
15         12

I filtered like this: dat1 <- dat1 %>% filter(row_number < '13') The result: instead of keeping all values <13, it removes values from 2 to 9.

dat1 %>% distinct(row_number)
# A tibble: 4 × 1
  row_number
       <dbl>
1          1
2         10
3         11
4         12

What s wrong with my codes?

Kinsley
  • 1
  • 2

0 Answers0