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

Thomas Roth (geb. Kaliwe) hamstersquats at web.de
Fri Jul 17 10:02:30 CEST 2009


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




More information about the R-help mailing list