# [Gretl-devel] some function suggestions/questions

Allin Cottrell cottrell at wfu.edu
Thu Jul 30 22:41:09 EDT 2009

```On Thu, 30 Jul 2009, Sven Schreiber wrote:

> Allin Cottrell schrieb:
> > On Wed, 29 Jul 2009, Sven Schreiber wrote:
> >
> >> Allin Cottrell schrieb:
> >>> On Mon, 20 Jul 2009, Sven Schreiber wrote:
> >>>
> >>>> in light of the recent discussion concerning mreverse() --for example we
> >>>> don't want too many different functions for doing similar things-- I
> >>>> would like to raise the following issues:
> >>>>
> >>>> 1) sort() and dsort(); IMHO it would be good to unify them into one
> >>>> function with an optional argument to specify descending sorting, like so:
> >>>> sort(a) or sort(a,0) : sorts ascending
> >>>> sort(a,1): sorts descending
> >>> Maybe so.  My only misgiving is that I prefer not to use magic
> >>> numbers (or magic booleans) as function arguments -- though we
> >>> already do this to some extent.
> >> I can understand both points of view, but what's the priority then? I
> >> tend to think that if sort() and dsort() are better than magic booleans,
> >> then the recently introduced mreverse(a) and mreverse(a,1) should also
> >> be replaced by rowreverse() and colreverse(). Don't know what other
> >> functions have similar issues. Having a mixture of "philosophies" with
> >> respect to function signatures is unnecessarily confusing IMHO.
> >
> > You're right on that.  I'll have to take a look at what we have in
> > place and take stock.
>
> FWIW, if it saves you the effort I could do that (based on the available
> documentation).

Thanks, Sven, but it seems there's just one case: mreverse.  On
second thoughts I wouldn't mind adding sort() to the list,
hence swallowing dsort().

While on the topic of cleaning up functions, I came across a
couple of candidates for scrapping: makemask() and nobs().  I'm
not sure I understand the doc for makemask, though I suppose I
must have added it once upon a time.  And as for nobs, it seems
this could easily be replaced via nobs(y) = sum(ok(y)), for series
argument y (i.e. the number of non-missing observations of y in
the current sample).

And while we're at it, do we need both ok() and missing()?
Strictly speaking, of course not, yet working around missing
observations is a fairly common task and it probably doesn't hurt
to have functions that go both ways, returning 1 for not-missing
and 1 for missing respectively.

Allin.
```