nwkeep

Keep networks or nodes

Syntax

nwkeep 
[netlist]
nwkeep 
[netname]
ifin
[,
clean]
   
clean Drop node observations

Description

Keeps a network or a list of networks. The command is the network version of keep and mirrors nwdrop.

It can also be used together with if or in. In this case, the command operates on the node-level and keeps only certain nodes of a network.

Examples

Load two networks and keep only one of them by name:

. nwclear
. nwrandom 5, prob(.4) name(net1)
. nwrandom 5, prob(.4) name(net2)
. nwkeep net2
. nwset

Keep only certain nodes of a network, using if:

. nwclear
. nwrandom 6, prob(.4) name(net3)
. nwkeep net3 if _n <= 3
. nwsummarize net3

nwcommands version 3.17.6, 9 November 2026 (check your installed version)


Back to top

nwcommands is free software under the GNU General Public License, version 3, as are the model packages nwsaom, nwergm, nwdynam and nwrem. Citing and licenses · Get help · GitHub. Issues with the core go to the nwcommands repository; issues with a model package go to that package's own repository.

This site uses Just the Docs, a documentation theme for Jekyll.