开发者

Scientific number handling

开发者 https://www.devze.com 2023-04-03 19:04 出处:网络
I am using package qvalue which has the following pre-processing step if(min(p)<0 || max(p)>1) {

I am using package qvalue which has the following pre-processing step

 if(min(p)<0 || max(p)>1) {
    print("ERROR: p-values not in valid range"); return(0)
    }
    if(length(lambda)>1 && length(lambda)<4) {
    print("ERROR: If length of lambda greater than 1, you need at least 4 values."); return(0)
    }
    m <- length(p)

I have 6000 values like the following: I could show them due to character limit of the overflow

[1] 0.3671178710 0.9360140780 0.2428194940 0.5185496048 0.3280692392
   [6] 0.4681617243 0.3654880576 0.3121728291 0.6357866236 0.2576397417
  [11] 0.7224965457 0.4020649535 0.1359902232 0.4313780172 0.7543924642
  [16] 0.1915732183 0.4359938726 0.2705147307 0.5155629834 0.4446611542
  [21] 0.6636414268 0.4666097886 0.5121170670 0.7911474854 0.0662147755
  [26]开发者_如何学JAVA 0.8659648750 0.0307181717 0.0910574293 0.7331402271 0.3078877515
  [31] 0.8331673742 0.4992904913 0.0773711040 0.6134791426 0.6714738843
  [36] 0.6620106441 0.3944466498 0.3330491388 0.7726571107 0.5989331217
  [41] 0.4429749257 0.7650029317 0.7608016901 0.3642432987 0.1672484189
  [46] 0.4305554981 0.4308085746 0.7999056710 0.8117493501 0.3325086551
  [51] 0.7233274303 0.4939756680 0.7763859166 0.8281922847 0.5195117763
  [56] 0.6581468025 0.7082172344 0.7201224910 0.8420571108 0.3118079731
  [5996] 0.3066819785 0.6066206806 0.7524323861 0.6815655815 0.7105895186

Whenever I fun the function for this variable: fdrq = qvalue(as.numeric( nd[,3]), fdr.level = 0.05 )

I am getting error:

[1] "ERROR: p-values not in valid range"

I tried to see the maximum and minimum, looks like it is in range.

> max(nd[,3])
[1] 1
> min(nd[,3])
[1] 0.0001641695

Please provide suggestion on what might be wrong ! is this something special on handling of decimal numbers ..... or this is a bug ...

Thanks;


I suspect that you have a value that's a tiny bit greater than 1, but that gets printed as "1":

> x <- 1.000000000000001
> x
[1] 1
> x > 1
[1] TRUE

You can configure R to display more digits:

> options(digits=20)
> x
[1] 1.000000000000001

A simple workaround might be to force all values greater than 1 to exactly 1.0:

> x <- c(1, 0.7, 1.000000000000001, 0.3, 0)
> x
[1] 1.000000000000000 0.700000000000000 1.000000000000001 0.300000000000000
[5] 0.000000000000000
> x[x>1] <- 1
> x
[1] 1.0 0.7 1.0 0.3 0.0

Whether this workaround is a sensible thing to do in your case, I don't know.

0

精彩评论

暂无评论...
验证码 换一张
取 消