简体   繁体   English

N在R中选择K功能不起作用 - 我缺少什么?

[英]N Choose K function in R not working--what am I missing?

I was trying to acquaint myself with R's nChooseK function but I can't get it to work. 我试图让自己了解R的nChooseK功能,但我无法让它发挥作用。 I thought it was part of the standard setup (ie no additional package needed). 我认为这是标准设置的一部分(即不需要额外的包)。

Please help. 请帮忙。 Here is what I tried: 这是我尝试过的:

> nChooseK(10,2) 
  Error: could not find function "nChooseK"
> n<-4;k<-2
> print(nChooseK(n,k)) 
 Error in print(nChooseK(n, k)) : could not find function "nChooseK"

the last one was an example I saw here: R basic nChooseK 最后一个是我在这里看到的一个例子: R basic nChooseK

The function is in the R.basic package which is not part of the default R installation. 该函数位于R.basic包中,该包不是默认R安装的一部分。 You probably meant to use just choose() . 你可能只想使用choose()

As joran mentions the function nChooseK is a part of R.basic. 正如joran提到的那样,函数nChooseKnChooseK的一部分。 You can tell this from the example you posted by looking at the top of the page: 您可以通过查看页面顶部的示例来说明这一点:


Rbasic Page


You'll notice the "R.basic" in the curley braces which tells you that that function is a part of the "R.basic" package. 您会注意到curley括号中的“R.basic”,它告诉您该函数是“R.basic”包的一部分。 So to use nChooseK you'll first need to load that package 因此,要使用nChooseK您首先需要加载该包

library(R.basic)

If you don't have R.basic installed yet then you'll need to install it 如果您还没有安装R.basic,那么您需要安装它

install.packages("R.basic", contriburl="http://www.braju.com/R/repos/")
library(R.basic)

But as noted the choose function in base R does the same thing 但是如前所述,基础R中的choose功能也是一样的

choose(37, 12)
#[1] 1852482996
nChooseK(37, 12)
#[1] 1852482996

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM