如何计算R中的组合和排列? [英] How to calculate combination and permutation in R?

查看:176
本文介绍了如何计算R中的组合和排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习Probability,并且我正在寻找在Linux上可以使用的工具。

I just started to learn Probability, and I'm looking for tools to work with on linux.

我找到了一些组合包http://rss.acs.unt.edu/Rdoc/library/Combinations/html/00Index.html,但当我尝试安装它们时,该过程失败,并显示以下消息:

I've found some Combinations packages http://rss.acs.unt.edu/Rdoc/library/Combinations/html/00Index.html but when I tried to install them, the process failled with the following message:

> install.packages("Combinations")
Installing package(s) into ‘/home/maxim/R/x86_64-pc-linux-gnu-library/2.13’
(as ‘lib’ is unspecified)
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘Combinations’ is not available (for R version 2.13.1)


推荐答案

您可以使用 combinat 包R 2.13:

You can use the combinat package with R 2.13:

install.packages("combinat")
require(combinat)
permn(3)
combn(3, 2)

如果您想知道组合数/ permutations,然后检查结果的大小,例如:

If you want to know the number of combination/permutations, then check the size of the result, e.g.:

length(permn(3))
dim(combn(3,2))[2]

这篇关于如何计算R中的组合和排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆