小编Abe*_*Abe的帖子

如何编写一个将参数传递给函数的函数?

我在R中编写一个函数来评估模型的拟合,但每个模型都采用相同的参数.如何避免对模型的每次调用重复相同的参数?

这里的论点可能更清楚

  data=data,
  na.action = na.exclude,
  subset = block == site)
Run Code Online (Sandbox Code Playgroud)

重复.

modelfit <- function(order, response, predictor, site) {
   if(order == 0) {
     m <- lm(response ~ 1, 
             data=data,
             na.action = na.exclude,
             subset = block == site)
   } else if (is.numeric(order)) {
     m <- lm(response ~ poly(predictor, order), 
             data=data,
             na.action = na.exclude,
             subset = block == site)
   } else if (order == 'monod') {
     x<-predictor
     m <- nls(response ~ a*x/(b+x),
              start = list(a=1, b=1),
              data=data,
              na.action = na.exclude,
              subset = …
Run Code Online (Sandbox Code Playgroud)

r function

2
推荐指数
1
解决办法
3002
查看次数

在C中将c('a''c','b')转换为c('a','a','c','c','b','b')?

给定变量向量,转换向量,以便重复每个变量

例如,我可以

sort(rep(c('a', 'c', 'b')))
Run Code Online (Sandbox Code Playgroud)

除了我不想对它们进行排序; 我想要它回来 c('a', 'a', 'c', 'c', 'b', 'b')

text r vector

2
推荐指数
1
解决办法
179
查看次数

R:从FUN(1.01)返回"1.0"?

我想将一个数字转换为指定数量的有效数字,例如一些返回"1.0"(作为一个字符)的函数FUN(1.01).(我需要一个字符,因为该值将用于xtable.

我怀疑这是微不足道的,但我遇到了麻烦.

这是我尝试过的:

> signif(1.01, 2)
[1] 1
> round(1.01, 2)
[1] 1.01
> format(1.01, digits = 2)
[1] "1"
> as.character(trunc(1.20, 3))
[1] "1"
> as.character(round(1.01, digits = 2))
[1] "1"
Run Code Online (Sandbox Code Playgroud)

有没有这样做的功能?

string r xtable

2
推荐指数
1
解决办法
82
查看次数

如何压缩目录,并将软链接转换为硬链接?

我想压缩一个目录.

tar -cvzf mydir.tar.gz mydir
Run Code Online (Sandbox Code Playgroud)

但这会保留符号链接,因此无法移植到新系统.

如何转换符号链接?

我试过了

tar -cvzfh 
Run Code Online (Sandbox Code Playgroud)

自从man tar说

-h, - dereference

          don’t dump symlinks; dump the files they point to
Run Code Online (Sandbox Code Playgroud)

但这会导致错误

tar: Error exit delayed from previous errors
Run Code Online (Sandbox Code Playgroud)

并创建一个名为"zh"的文件

我的文件位于RHEL服务器上.

compression bash symlink rhel tar

0
推荐指数
1
解决办法
570
查看次数

标签 统计

r ×3

bash ×1

compression ×1

function ×1

rhel ×1

string ×1

symlink ×1

tar ×1

text ×1

vector ×1

xtable ×1