我正在寻找一个功能
1:n)满足第一个要求,例如,permn()从包装combinat,permutations()包装e1071或permutations()包装gtools.但是,我很肯定,某些软件包还有另一个功能,它也提供了第二个功能.我用了一次,但后来忘记了它的名字.
编辑:"前N"的定义是任意的:函数只需要一个始终遵循的内部枚举方案,并且应该在计算N个排列后中断.
正如Spacedman正确指出的那样,至关重要的是,该函数不会计算比实际需要更多的排列(以节省时间).
编辑 - 解决方案:我记得我在使用它,它numperm()来自包sna.numperm(4, 7)给出元素的第7个排列1:4,对于前N个,必须循环.
我正在尝试使用nanoc 3.5.0和使用的pandoc过滤器pandoc-ruby.具体来说,我无法从我的Rules文件中传递几个选项,以便最终调用PandocRuby.convert()如下所示:
PandocRuby.convert(content,
{:from => :markdown, :to => :html}, :no_wrap,
:table_of_contents, :mathjax, :standalone,
{"template" => Dir.getwd + '/layouts/pandocTemplate.html'})
Run Code Online (Sandbox Code Playgroud)
当我将上述调用放在自定义过滤器中时,一切正常.但是,我想指定pandoc选项,Rules这样我就不必为每组选项创建一个特殊的过滤器.
默认的pandoc过滤器被定义为函数run(content, params={})并且只是调用PandocRuby.convert(content, params).如何设置params,使得PandocRuby.convert()被称为正确?以下指令Rules不起作用:
filter :pandoc, :params => { :from => :markdown, :to => :html, :no_wrap, :table_of_contents, :mathjax, :standalone, "template" => Dir.getwd + '/layouts/pandocTemplate.html' }
filter :pandoc, :params => { :from => :markdown, :to => :html, :no_wrap => true, :table_of_contents => true, …Run Code Online (Sandbox Code Playgroud) 我的目标是在R中编写一个接受分数多项式(FP)系数的函数,并返回一个矢量化函数,该函数评估给定输入数的指定FP.FP定义有两个重要规则:
我下面的当前解决方案将FP函数构建为字符串,解析字符串并返回一个计算表达式的函数.我的问题是,是否有更好/更快的方法可以避免eval(parse())- 可能使用一些substitute()魔法.
该函数必须处理每个电源的系数数量事先未知,但在被调用时指定.最终的FP评估需要很快,因为它经常被调用.
这将是很好不限于标准功率-2,-1,-0.5,0,0.5%,1,2,3,理想情况下,所需的功能会做两个步骤在一次:接受FP-系数以及数字向量并返回输入的FP值,同时仍然很快.
getFP <- function(p_2, p_1, p_0.5, p0, p0.5, p1, p2, p3, ...) {
p <- as.list(match.call(expand.dots=TRUE)[-1]) # all args
names(p) <- sub("^p", "", names(p)) # strip "p" from arg names
names(p) <- sub("_", "-", names(p)) # replace _ by - in arg names
## for one power and the i-th coefficient: build string …Run Code Online (Sandbox Code Playgroud)