1

每当我在脚本中运行它时,R 中的命令似乎summary都是空白的,即使它在命令行中运行良好。

这是我的脚本:

suppressMessages(library("statnet"))

#Simple example using a 3-node network
n<-network.initialize(3, directed=T) #generate an empty 3 node network
n[1,2]<-1  #assign a single link between node 1 and node 2
gplot(n)  #plot the network

e1<-ergm(n~edges)  #conduct an ergm using only the edges term

summary(e1)

不,删除suppressMessages没有帮助。这个脚本的结果是这样的:

root@user:~/NetworkStatsData$ r test.R
Evaluating log-likelihood at the estimate.

而已。绝对没有summary命令。现在,当我在命令行中运行完全相同的命令时,我得到了这个结果:

root@user:~/NetworkStatsData$ R

R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> suppressMessages(library("statnet"))
> n<-network.initialize(3, directed=T)
> n[1,2]<-1
> gplot(n)
> e1<-ergm(n~edges)
Evaluating log-likelihood at the estimate. 
> summary(e1)

==========================
Summary of model fit
==========================

Formula:   n ~ edges

Iterations:  4 out of 20 

Monte Carlo MLE Results:
      Estimate Std. Error MCMC % p-value
edges   -1.609      1.095      0   0.202

     Null Deviance: 8.318  on 6  degrees of freedom
 Residual Deviance: 5.407  on 5  degrees of freedom

AIC: 7.407    BIC: 7.198    (Smaller is better.) 
>

这是我在运行脚本时想要发生的事情。为什么一个人的行为与另一个人的行为不同?

4

0 回答 0