Remove NA when using "order"
The na.last
argument to order
only removes NA
from the objects passed to order
via ...
. Your NA
are in aa$precipitation
, not aa$year
, aa$month
, or aa$day
, so you need:
dat <- na.omit(aa[order(aa$year, aa$month, aa$day),])
You may want to consider using a time-series class like zoo or xts for time-series data.
Because na.last
is to see if NA
should be last of first when ordering not to remove the NA
. Use na.omit(dat)
to remove the NA
.
Hope that helps.