Re: [R] Warning message in if else statement

From: Monica Pisica <pisicandru_at_hotmail.com>
Date: Wed, 23 Jul 2008 18:35:20 +0000

Hi again,  

It seems one line in my function came chopped for whatever reason ....  

so the if else statement below should be: if (pval==0) p_value <- "<2.2e-16" else p_value <- pval  

Thanks,  

Monica    

> Date: Wed, 23 Jul 2008 13:24:45 -0500> From: markleeds@verizon.net> Subject: Re: [R] Warning message in if else statement> To: pisicandru@hotmail.com> > hi monica: i don't understand the statement below. could that be related > to your problem ?> > if (pval==0) p_value <- "<- pval> > > > > > On Wed, Jul 23, 2008 at 2:11 PM, Monica Pisica wrote:> > > Hi Erik,> >> > Thanks for your answer. I did print the p-value just before the > > statement and it is only one value or at least I see only one value > > .. that is strange.> >> > I am doing a test and I want to see what is it's p-value .for example > > my function "myf" is like that:> >> > myf <- function(m, se, conf.int)> > {> > z <- qnorm((1+conf.int)/2)> > pval <- (1 - pnorm(abs(m/se)))*2> > if (pval==0) p_value <- "<- pval> > tst <- data.frame(m/se, p_value, m - z*se, m + z*se)> > names(tst) <- c("m/se", "p-value", "C.I.1","C.I.2")> > print(tst, quote = F)> > }> > If m = 0.3913681 and se = 0.04628602 pval = 0 so I am testing if pval > > = 0 and I am reporting a very small number . Maybe I should report 0 > > but sincerely I don't quite like it so I rather report a p-values less > > than 2.2e-16 which is 0 for all practicality I would say. If I use > > this function as it is . No problems, if I incorporate inside a > > different function so to be used internally I get the warning. Any > > idea why?> >> > Thanks,> >> > Monica> >> >> >> >> Date: Wed, 23 Jul 2008 12:24:55 -0500> >> From: iverson@biostat.wisc.edu> >> To: pisicandru@hotmail.com> >> CC: r-help@r-project.org> >> Subject: Re: [R] Warning message in if else statement> >>> >> Monica -> >>> >> Monica Pisica wrote:> >>> Hi,> >>>> >>> I am using an if else statement inside a function . If I use that> >>> function I have no problems . If I use the function with the if > >>> else> >>> statement inside a second function I get the following waring:> >>>> >>> Warning message: In if (pval == 0) p_value <- "< 2.2e-16" else> >>> p_value <- pval : the condition has length> 1 and only the first> >>> element will be used> >>> >> This means that pval has more than one element, try printing its > >> value> >> immediately before the if statement to see what it is and how it got> >> that way.> >>> >> I also might ask what exactly you're doing with 'real p-values' and> >> testing whether they equal 0?> >>> >>>> >>> Using the second function I get the expected results, with a real> >>> p-value even if it is extremely small, or "> >>> _________________________________________________________________> >>> [[elided Hotmail spam]]> >>>> >>> ______________________________________________ R-help@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.> >>>> >> > _________________________________________________________________> >> >> > enger2_072008> > ______________________________________________> > R-help@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.


enger2_072008

        [[alternative HTML version deleted]]



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. Received on Wed 23 Jul 2008 - 18:41:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jul 2008 - 19:32:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive