1 Star 1 Fork 7

连享会/nwcommands

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
nwvalue.ado 1.87 KB
Copy Edit Raw Blame History
ThomasGrund authored 2015-09-18 19:13 . v1.5.1
*! Date : 24aug2014
*! Version : 1.0
*! Author : Thomas Grund, Linkoping University
*! Email : contact@nwcommands.org
capture program drop nwvalue
program nwvalue
local netname ="`0'"
// a specific entries are given
local ego = strpos("`netname'","[")
local alter = strpos("`netname'","]")
local sep = strpos("`netname'",",")
local subset = substr("`netname'",`ego',.)
if (`ego' != 0) {
local e1 = `ego' + 1
local e2 = `sep' - `ego' - 1
local a1 = `sep' + 1
local a2 = `alter' - `sep' - 1
local n1 = `ego' - 1
local egoid = substr("`netname'", `e1', `e2')
local alterid = substr("`netname'", `a1', `a2')
local netname = substr("`netname'", 1, `n1')
}
nwtomatafast `netname'
mata: onenet = `r(mata)'
//nwtomata `netname', mat(onenet)
capture mata: onenet`subset'
if _rc != 0 {
di "{err}{it:nwsubset} {bf:`subset'} invalid"
error 6400
}
mata: st_rclear()
if (`ego'!= 0) {
/*
if "`exp'" != "" {
local exp : subinstr local exp "=" ""
mata: onenet[`egoid',`alterid'] = J(rows(onenet[`egoid',`alterid']), cols(onenet[`egoid',`alterid']), `=`exp'')
}
*/
mata: subnet = onenet[`egoid',`alterid']
mata: st_numscalar("r(rows)", rows(subnet))
mata: st_numscalar("r(cols)", cols(subnet))
if (`r(rows)' == 1 & `r(cols)' == 1) {
mata: st_rclear()
mata: st_numscalar("r(ego)", `egoid')
mata: st_numscalar("r(alter)", `alterid')
mata: subnet[1,1]
mata: st_numscalar("r(value)", subnet[1,1])
}
else {
mata: st_matrix("r(values)", subnet)
mata: subnet
}
}
else {
mata: subnet = onenet
mata: subnet
mata: st_numscalar("r(rows)", rows(subnet))
mata: st_numscalar("r(cols)", cols(subnet))
mata: st_matrix("r(values)", subnet)
}
capture mata: mata drop subnet
end
*! v1.5.0 __ 17 Sep 2015 __ 13:09:53
*! v1.5.1 __ 17 Sep 2015 __ 14:54:23
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/arlionn/nwcommands.git
git@gitee.com:arlionn/nwcommands.git
arlionn
nwcommands
nwcommands
master

Search