小编Ven*_*Yao的帖子

如何在R中的对称矩阵(12k X 12k)中找到前10,000个元素的索引

我有一个非零对称矩阵'matr',即12000X12000.我需要找到R中'matr'中前10000个元素的索引.我写的代码需要很长时间 - 我想知道是否有任何指针可以让它更快.

listk <- numeric(0)
for( i in 1:10000) {
    idx <- which(matr == max(matr), arr.ind=T)
    if( length(idx) != 0) {
        listk <- rbind( listk, idx[1,])
        matr[idx[1,1], idx[1,2]] <- 0
        matr[idx[2,1], idx[2,2]] <- 0
    } 
}
Run Code Online (Sandbox Code Playgroud)

r matrix

9
推荐指数
3
解决办法
3878
查看次数

闪亮的渲染UI错误

我使用 编写了一个小型闪亮应用程序renderUI。它运行正确,但R控制台抛出错误消息

if (nchar(locus) == 12) { 中的错误:参数长度为零

每次我运行这个应用程序时。

这是我的脚本。

服务器.R:

load("rapmsu.rda")
convMSU <- function(locus="Os02g0677300") {
  if (nchar(locus)==12) {
    return(rapmsu[rapmsu$rap==locus,])
  } else {
    return(NULL)
  }
}
convRap <- function(locus="LOC_Os03g57940") {
  if (nchar(locus)==14) {
    return(rapmsu[rapmsu$msu==locus,])
  } else {
    return(NULL)
  }
}
convID <- function(query="", text="") {
  if (query=="RAPdb Locus") {
    return(convMSU(text))
  } else if (query=="MSU Locus") {
    return(convRap(text))
  }
}

query.intext.conv <- c("Os02g0677300", "LOC_Os03g57940")
names(query.intext.conv) <- c("RAPdb Locus", "MSU Locus")

#### Shiny
shinyServer(function(input, output) {

  output$inTextconv <- …
Run Code Online (Sandbox Code Playgroud)

r render shiny

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

标签 统计

r ×2

matrix ×1

render ×1

shiny ×1