Home>

### when using a sequence for filter processing, some rows that meet the conditions disappear

`storms`With`dplyr`I am practicing to use.
I tried to extract the storms of the 1990s (1990-1999) as follows.

``storms1990s<-filter (storms, year == 1990: 1999)``

But the result is some storms for some reason (`year == 1990: 1999`) Was excluded (for example, 1991)`Fabian`A storm named`storms1990s`Was excluded from).`seq ()`I also tried, but it became the same.

How to set the conditions`year>= 1990&year<= 1999`I solved this problem, but I don't understand why the sequence didn't work.

I would be grateful if anyone could tell me.

• Answer # 1

It is a specification of comparison operation in R.

If the vector lengths are different, the elements of the shorter vector are used in a circular manner.
The vector and the corresponding elements of the vector are compared, and the logical type vector described later is returned as the result.

here`filter ()`What is being executed in`storms \$year == 1990: 1999`It is a comparison operation.
In R`A == B`When attempting an operation such as, the number of elements in B must be an integral multiple of the number of elements in A (including, of course, 1 times = the same number). Otherwise, the result will probably be quite different from what you expected.
In conclusion, comparisons using "sequences" are not suitable for this occasion.