我在一个文件中有以下脚本(称之为“temp.R”):
library(ape)
tree <- rbdtree(0.5, 0.05, 5)
bd.time(tree, 0, 0)
当我运行时,Rscript temp.R
我得到了一些结果:
$par
birth death
0.5289875 0.0000000
$SS
[1] 9.21573
$convergence
[1] 0
$iterations
[1] 6
$evaluations
function gradient
8 16
$message
[1] "relative convergence (4)"
但是,当我运行 R 然后执行以下操作时:
source('temp.R')
我收到以下错误:
Error in integrate(Pi, 0, Tmax) : non-finite function value
有谁知道为什么Rscript
和之间存在差异source
,一个有效而另一个失败?如果有帮助,这是version
在 R 中运行的输出:
_
platform x86_64-apple-darwin10.8.0
arch x86_64
os darwin10.8.0
system x86_64, darwin10.8.0
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
更新:当我Rscript temp.R
多次运行时,有时会收到与运行时类似的错误消息source
:
Error in integrate(Pi, 0, Tmax) : non-finite function value
Calls: bd.time ... objective -> CDF.birth.death -> .CDF.birth.death2 -> integrate
Execution halted