[R] SOLVED: how to evaluate character vector within pnorm()

Thomas Roth (geb. Kaliwe) hamstersquats at web.de
Fri Jul 17 14:20:48 CEST 2009


That what i was looking for :-)

Bill.Venables at csiro.au schrieb:
> Here is one way:
>
>
> x <- c(2,3)
> names(x) <- c("mean", "sd")
>
> do.call(pnorm, c(list(0), as.list(x)))
>
>  
>
>
> Bill Venables
> http://www.cmis.csiro.au/bill.venables/ 
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Thomas Roth (geb. Kaliwe)
> Sent: Friday, 17 July 2009 6:03 PM
> To: 'r-help at r-project.org'
> Subject: [R] how to evaluate character vector within pnorm()
>
> Hi,
>
> I'm trying to evaluate a character vector within pnorm. I have a vector 
> with values and names
>
> x = c(2,3)
> names(x) = c("mean", "sd")
>
> so that i tried the following
>
> temp = paste(names(x), x, sep = "=")
>
> #gives
> #> temp
> #[1] "mean=2" "sd=3"
>
> #Problem is that both values 2 and 3 are taken as values for the mean 
> argument in pnorm
> pnorm(0, eval(parse(text = temp)) )
>
> #but not as
> pnorm(0, mean = 2, sd = 3 )
>
>
> #How can i get
>
> pnorm(0, eval(parse(text = temp)) )
>
> #to do
>
> pnorm(0, mean = 2, sd = 3 )
>
>
>
> Thank you for your time
>
> Thomas Roth
>
> ______________________________________________
> 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.
>
>




More information about the R-help mailing list