小编Hon*_*Ooi的帖子

在delphi中初始化对象

如你所知,在c#中初始化对象非常方便快捷

    StudentName student2 = new StudentName
    {
        FirstName = "Craig",
        LastName = "Playstead",
    };
Run Code Online (Sandbox Code Playgroud)

List<MyObject>.Add(new MyObject{a=1,b=2})
Run Code Online (Sandbox Code Playgroud)

可以像这样在Delphi中初始化对象吗?

delphi delphi-xe4

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

R中的NSLOOKUP(rstats)

我是脚本和R的新手.

在Windows cmd.exe中,我可以通过以下方式在域上执行NSLOOKUP:

nslookup www.google.com

我有一个域名数据集,我想验证它是有效的还是无效的,作为我在R中的分组过程的一部分.有没有办法在基础R或其中一个包中进行NSLOOKUP?

编辑1:我做了一些改动,使用建议的系统调用循环3个域.调用有效,但输出不会直接保存到向量中(下面的第7行).我怎么需要重新修改这一行才能捕获输出?

domains <- c('www.google.com','www.badtestdomainnotvalid.com','www.yahoo.com')
dns <- vector()
dnsreturn <-vector()
for(i in 1:length(domains)){
  dns[i] <- paste('nslookup ',domains[i],sep='')
  dnsreturn[i] <- system(dns[i],intern=TRUE)}
}
Run Code Online (Sandbox Code Playgroud)

nslookup r

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

计算行总和但排除R中的列

我想计算列的总和,但排除一列.如何在添加每行的总和时指定要排除的列.

hd_total<-rowSums(hd) #hd is where the data is that is read is being held 
hn_total<-rowSums(hn)
Run Code Online (Sandbox Code Playgroud)

r

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

使用 ResourceChangeListener AEM 6.3 处理事件

有人可以帮助我理解如何实现 ResourceChangeListener 并使用 osgi R6 注释处理事件吗?我看到一个类似的帖子,没有答案。AEM 6.3 - 使用 OSGi R6 注释创建事件处理程序

osgi annotations addeventlistener aem

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

通过Rcpp传递Armadillo稀疏矩阵

这个问题关系到这个这个。此处的区别在于,我没有传递Rcpp类型(例如NumericVector或)NumericMatrix,而是传递arma::sp_mat

有什么方法可以将A传递sp_mat给C ++,修改其值,并使更改显示在R中的原始对象中吗?

可以使用来完成NumericMatrix,例如:

cppFunction("void frob(NumericMatrix& x)
{
    for(NumericMatrix::iterator it = x.begin(); it != x.end(); ++it)
    {
        if(*it != 0) *it = *it + 5;
    }
}")

M <- Matrix(0, 5, 1, sparse=TRUE)
M[1] <- 1.2345

m <- as.matrix(M)

frob(m)
m
       #[,1]
#[1,] 6.2345
#[2,] 0.0000
#[3,] 0.0000
#[4,] 0.0000
#[5,] 0.0000
Run Code Online (Sandbox Code Playgroud)

相同的技术适用于arma::mat密集矩阵。但是对于稀疏矩阵,它不起作用:

cppFunction("void frob2(arma::sp_mat& x)
{
    for(arma::sp_mat::iterator it = x.begin(); it != x.end(); …
Run Code Online (Sandbox Code Playgroud)

r sparse-matrix armadillo rcpp

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

在 download.file 中关闭 SSL 验证

有没有办法在默认情况下禁用 SSL 验证download.file

情况是我们公司有一个内部 CRAN 镜像,但它使用自签名 SSL 证书。据我所知,这会导致download.file失败,并且由于install.packages使用了download.file,这意味着安装软件包也会失败。我想关闭验证检查以查看是否可以解决问题。

操作系统是Ubuntu 20.04(实际上在容器内运行),R是4.1.1。

r libcurl ssl-certificate

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

R 中的错​​误...缺少需要 TRUE/FALSE 的值

以下是我的 R 脚本的一部分:

for (i in 1:N-1) {
  if (-50<nw.bank[i] && 50>nw.bank[i]) {
      rl[i+1] <- (rl[i]+0.001)
  } 
    else {
      rl[i+1] <- rl[i]
  }
}
Run Code Online (Sandbox Code Playgroud)

运行时,我收到以下消息:

"Error in if (-50 < nw.bank[i] && 50 > nw.bank[i]) { : 
  missing value where TRUE/FALSE needed"
Run Code Online (Sandbox Code Playgroud)

谁能帮我吗?非常感谢!

最好的,炫

if-statement r

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

为什么all.equal(1,2,3)返回TRUE

我试过all.equal(1,2),它的平均差异为1.

为什么要all.equal(1,2,3)表演TRUE

是因为如果它提供了两个以上的变量,它在不同的元素上运行.numeric()来检查它们的类型而不是数值差异?

r

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

如何正确返回dplyr的字符值呢?

请考虑以下代码:

foo <- function() {
  if (runif(1) < 0.5) {
    return(data.frame(result="low"))
  } else {
    return(data.frame(result="high"))
  }
}

df = data.frame(val=c(1,2,3,4,5,6))
df %>% group_by(val) %>% do(foo())
Run Code Online (Sandbox Code Playgroud)

它是随机的,但如果同时返回"低"和"高"结果,您将看到如下错误:

Warning messages:
1: In bind_rows_(x, .id) : Unequal factor levels: coercing to character
2: In bind_rows_(x, .id) :
  binding character and factor vector, coercing into character vector
3: In bind_rows_(x, .id) :
  binding character and factor vector, coercing into character vector
4: In bind_rows_(x, .id) :
  binding character and factor vector, coercing into character …
Run Code Online (Sandbox Code Playgroud)

r dataframe dplyr

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

尝试使用 Github Actions 复制存储库时出现身份验证错误

我有一堆使用 Azure Pipelines 进行 CI/CD 的存储库,我现在正在尝试将其移植到 Github Actions。这是我正在研究的第一个:https://github.com/Azure/AzureAuth/tree/fix-ghaction

我已经完成了 99% 的工作,但在某一步骤中我遇到了奇怪的身份验证错误。该存储库已镜像到另一个组织(cloudyr),我使用此步骤进行镜像:

  - name: Copy to Cloudyr
    if: runner.os == 'Linux'
    env:
      token: "${{ secrets.ghPat }}"
    run: |
      export CLOUDYR_REPO=$(echo $GITHUB_REPOSITORY | sed "s/Azure/cloudyr/")
      git push --prune https://$token@github.com/${CLOUDYR_REPO}.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*
Run Code Online (Sandbox Code Playgroud)

这会从存储库机密中检索 PAT,并执行git push. 它与 Azure Pipelines 完美配合,但现在失败并出现以下错误:

Run export CLOUDYR_REPO=$(echo $GITHUB_REPOSITORY | sed "s/Azure/cloudyr/")
remote: Permission to cloudyr/AzureAuth.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/cloudyr/AzureAuth.git/': The requested URL returned error: 403
Error: Process completed with exit code …
Run Code Online (Sandbox Code Playgroud)

git github github-actions

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