Home>

stormsWithdplyrI 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)FabianA storm namedstorms1990sWas excluded from).seq ()I also tried, but it became the same.

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

I would be grateful if anyone could tell me.

r
  • 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.

    herefilter ()What is being executed instorms $year == 1990: 1999It is a comparison operation.
    In RA == BWhen 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.