gtools-1.5.1
Release update. New commands, major features, and various bug fixes. Remember to run gtools, upgrade
to keep up to date between major updates.
New Commands
-
gstats winsor
is a fast, by-ablewinsor2
alternative for Winsorizing and trimming data (accepts weights). -
greshape long
andgreshape wide
are a fast alternative to reshape. -
greshape spread
andgreshape gather
are analogous to thespread
andgather
commands from R'stidyr
. -
gstats sum
andgstats tab
(aliasgstats summarize
andgstats tabstat
) are a fast, by-able alternative tosum, detail
andtabstat
Enhancements and Features
-
gstats sum
orgstats tab
with optionmatasave
; this stores the output and by levels inGstatsOutput
(custom naming viamatasave(name)
), an object of classGtoolsResults
. -
gcollapse
andgegen
now allow the stats:select#
andselect-#
, for the#
th smallest or largest value, respectively.rawselect#
andrawselect-#
, ibid but ignoring weights.cv
, coefficient of variation,sd/mean
variance
range
,max
-min
-
greshape
features- Preferred syntax is
by()
andkeys()
instead ofi()
andj()
; the docs and most of the printouts reflect this. greshape
tries to save variable labels, notes, and characteristics when reshaping.greshape, uselabels
allows the user to save the source variable labels as levels instead of their names.greshape
supports @ syntax.greshape wide
additionally supports varlist syntax (but the same stub cannot have both@
and a varlist).greshape long
does not support varlist syntax, but the user can pass regexes as stubs with the optionmatch(regex)
. See the documentation for details.
- Preferred syntax is
-
glevelsof
andgtop
featuresglevelsof
andgtop
both take optionmatasave
(ormatasave(name)
) to save the variable levels in a mata object (default name isGtoolsByLevels
).- With option
matasave[(name)]
,r(levels)
is not returned; the levels are stored inprinted
as part of the mata return object (e.g.GtoolsByLevels.printed
). The user can save only the raw levels by also adding thesilent
option. - With option
matasave[(name)]
, bothgtop, numfmt()
andglevelsof, numfmt()
do the number formatting in mata, sonumfmt()
must pass a mata print format instead of a C print format (they are very similar, however). - With option
matasave[(name)]
,gtop
does not returnr(toplevels)
either. The frequency table is stored intoplevels
as part of the mata return object (e.g.GtoolsByLevels.toplevels
). gtop, ntop(.)
prints all the levels from largest to smallest;gtop, ntop(-.)
prints from smallest to largest;gtop, alpha
prints the largest/smallestntop()
levels sorted in variable order (e.g. alphabetically or numerically, depending on the variable type).gtop
also storesr(ntop)
,r(nrows)
, andr(alpha)
as return scalars; ifntop(.)
orntop(-.)
are passed,r(ntop)
will just ber(J)
.- Both
gtop
andglevelsof
should handle embedded characters better. Printing is still a problem but they get copied to the return values properly.
-
gstats
is a general-purpose wrapper for misc functions. -
lgtools.mlib
added with come pre-compiled mata functios. -
Any function that allows results to be saved in mata allow the mata object to call
.desc()
to get more info on the object. -
Faster hash sort with integer bijection (two-pass radix sorts for smaller integers; undocumented option
_ctolerance()
allows the user to force the regular counting sort). -
Faster index copy when every observation is read (simply assign the index pointer to
st_info->index
)
Bug Fixes
-
Stata 14.0 no longer tries to load SPI version 3 (loads version 2).
-
SpookyHash code compiled directly as part of the plugin. Might fix #35 (deleted all ancillary files and code related to
spookyhash.dll
). -
gtop
,glevelsof
, andgcontract
parse wildcards before adding any temporary variables, ensuring the latter don't get included in internal function calls. -
Removed locale as a dependency; comma printing done manually. This fixes a bug where in certain systems, locale would get reset and cause some internal Stata numbers fo interpret decimals via comma, that is,
95.0
would become95,0
and cause problems down the line. -
Minor bug fix in
gtop
; inverted levels were not correctly sorted with weights. The levels themselves were OK, however. -
gcollapse
no longer crashes whenrawstat
does not match any entries.