为什么rbinom在R给我这里?

时间:2016-03-01 23:37:56

标签: r na

经过一些调试后,我将问题缩小到以下几个方面:

  minc <- function(split, population, base, lift = 0.1) {
      control.pop <- population * (1- split)
      test.pop <- population*split

      control.cr <- base
      test.cr <- control.cr*(1+lift)

      #### print statements ####
      print(c(control.pop, control.cr))  # print values of variables
      print( rbinom(1, 5800.0 , 0.1)) # print rbinom for the values
      print( rbinom(1, control.pop, control.cr))  # print rbinom for the variables
    }


    minc(0.8, population = 29000, base = 0.1, lift = 0.1)

给出输出

[1] 5800.0    0.1
[1] 589
[1] NA

即 我打印传递的变量的值,然后打印这些值的rbinom - 它工作正常 - 但是当我为变量做rbinom时,我得到NA。这里发生了什么?

1 个答案:

答案 0 :(得分:1)

Rbinom想要一个你可以做的大小的整数

control.pop <- round(population * (1 - split))

正如@ ben-bolker指出的那样使用.overlay { position: absolute; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; } 会舍入到整数而不是截断:

03 - 01 18: 44: 57.988 18868 - 18933 / ? E / AndroidRuntime : FATAL EXCEPTION: pool - 5 - thread - 1 Process: com.keycorp.kmf, PID: 18868 java.lang.UnsatisfiedLinkError: Couldn 't load authjni from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.keycorp.kmf-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.keycorp.kmf-1, /vendor/lib, /system/lib]]]: findLibrary returned null at java.lang.Runtime.loadLibrary(Runtime.java: 358) at java.lang.System.loadLibrary(System.java: 526) at com.worklight.common.security.AppAuthenticityToken. < init > (AppAuthenticityToken.java: 30) at com.worklight.wlclient.challengehandler.AuthenticityChallengeHandler.handleChallenge(AuthenticityChallengeHandler.java: 81) at com.worklight.wlclient.challengehandler.AuthenticityChallengeHandler.handleChallenge(AuthenticityChallengeHandler.java: 32) at com.worklight.wlclient.api.challengehandler.BaseChallengeHandler.startHandleChallenge(BaseChallengeHandler.java: 71) at com.worklight.wlclient.WLRequest.checkResponseForChallenges(WLRequest.java: 626) at com.worklight.wlclient.WLRequest.requestFinished(WLRequest.java: 292) at com.worklight.wlclient.WLRequestSender.run(WLRequestSender.java: 52) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 587) at java.lang.Thread.run(Thread.java: 841) 03 - 01 18: 44: 57.998 18868 - 18881 / ? E / com.worklight.common.Logger$UncaughtExceptionHandler : Logger$UncaughtExceptionHandler.uncaughtException in Logger.java: 452::Uncaught Exception java.lang.UnsatisfiedLinkError: Couldn 't load authjni from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.keycorp.kmf-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.keycorp.kmf-1, /vendor/lib, /system/lib]]]: findLibrary returned null at java.lang.Runtime.loadLibrary(Runtime.java: 358) at java.lang.System.loadLibrary(System.java: 526) at com.worklight.common.security.AppAuthenticityToken. < init > (AppAuthenticityToken.java: 30) at com.worklight.wlclient.challengehandler.AuthenticityChallengeHandler.handleChallenge(AuthenticityChallengeHandler.java: 81) at com.worklight.wlclient.challengehandler.AuthenticityChallengeHandler.handleChallenge(AuthenticityChallengeHandler.java: 32) at com.worklight.wlclient.api.challengehandler.BaseChallengeHandler.startHandleChallenge(BaseChallengeHandler.java: 71) at com.worklight.wlclient.WLRequest.checkResponseForChallenges(WLRequest.java: 626) at com.worklight.wlclient.WLRequest.requestFinished(WLRequest.java: 292) at com.worklight.wlclient.WLRequestSender.run(WLRequestSender.java: 52) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 587) at java.lang.Thread.run(Thread.java: 841) 03 - 01 18: 46: 07.878 19193 - 19206 / ? D / NONE : establishSSLClientAuth 03 - 01 18: 46: 07.938 19193 - 19206 / ? D / NONE : establishSSLClientAuth isCertificateExists: false