It is not simply the answer, it is a list
str(integrate(dnorm, -1.96, 1.96))
List of 5
$ value : num 0.95
$ abs.error : num 1.05e-11
$ subdivisions: int 1
$ message : chr "OK"
$ call : language integrate(f = dnorm, lower = -1.96, upper = 1.96)
- attr(*, "class")= chr "integrate"
Is this what you want (?):
1 + (integrate(dnorm, -1.96, 1.96)[[1]])
ChrisQ wrote:>
> Hi,
>
> I need to do a calculation in R which involves adding the estimate of a
> numerical integration with another number - however, if I add the number
> to
> the output of the intergrate function (which when run on its own provides
> me
> with a number with error), I get the message 'non-numeric argument to
> binary
> operator'. How would I be able to avoid this and use the estimate?
>
> eg: I have the code integrate(dnorm, -1.96, 1.96), which gives the output
> 0.9500042 with absolute error < 1.0e-11, but if I put in
integrate(dnorm,
> -1.96, 1.96)+1, I don't get 1.9500042 - how would I?
>
> Thanks very much, Chris.
>
> --
> View this message in context:
>
http://r.789695.n4.nabble.com/Help-with-Integration-Output-tp3839360p3839360.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
View this message in context:
http://r.789695.n4.nabble.com/Help-with-Integration-Output-tp3839532p3839552.html
Sent from the R help mailing list archive at Nabble.com.