小编Dan*_*iel的帖子

perl:为什么$ hashsize = keys $ hash {$ foo}给出实验警告,我怎样才能更好地编写它?

我有一个哈希由两个因素决定(我不知道这是什么正确的术语),我生成如下:

if (exists $cuthash{$chr}{$bin}){
    $cuthash{$chr}{$bin} += 1;
}else{
    $cuthash{$chr}{$bin} = 1;
}
Run Code Online (Sandbox Code Playgroud)

我后来想要获取哈希的每个$ chr部分的大小,这在我做的时候有效:

for my $chr (sort keys %cuthash){
    my $hashsize = keys $cuthash{$chr};
    ...
}
Run Code Online (Sandbox Code Playgroud)

但我得到警告:

keys on reference is experimental at ../test.pl line 115.
Run Code Online (Sandbox Code Playgroud)

它有效,但显然它并不完美.什么是更好的方法?

谢谢

perl hash warnings

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

无法使用基本数据集在R和ggplot中显示轮廓

我试图将一些NMDS坐标绘制为x和y,并使用多样性度量(shannon)绘制为轮廓但我不断得到以下错误,我不明白为什么......

Error in if (empty(new)) return(data.frame()) : 
  missing value where TRUE/FALSE needed
Run Code Online (Sandbox Code Playgroud)

我的代码是:

all_merge <-read.table("test.txt", header=TRUE)

 p <- ggplot(all_merge, aes(NMDS1, NMDS2, z = shannon))
 p + geom_contour()
Run Code Online (Sandbox Code Playgroud)

我的数据集是:

NMDS1   NMDS2   shannon
-0.287555952    -0.129887595    9.516558582
-0.314104852    -0.048655648    8.985087924
-0.214910534    -0.127167065    8.928241917
-0.341295065    -0.296282805    8.315476782
-0.470025718    0.083835083 8.494348157
-0.429386114    0.044064347 8.669813919
-0.427608469    0.124631936 8.15886319
-0.584412991    0.257278736 8.469688185
-0.436526047    -0.070633108    8.496878956
-0.584707076    0.120411579 8.319057817
0.183493022 0.445239412 5.611249955
0.172968855 0.583787121 5.728358304
-0.404838098    -0.0271276  8.679667562
-0.458718755    -0.05638174 8.714026645
0.458621093 -0.186746574    8.094002558
1.148457698 0.044192391 6.058046032
0.346825668 …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

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

制作R循环以更恰当地找到箱子R.

我写了一个小循环来找出哪个'bin'是一个数字,但我觉得它是相当pythonic而不是R.是否有更合适的方法来做到这一点,还是正常?

  binLimits <- seq(0, 70, 10)
  binNames <- c("A","B","C","D","E","F","G")

  pos <- 45

  # Find which bin pos is in
  n <-0
  for (i in binLimits){
    if (pos < i){
      pos.bin <- binNames[n]
      break
    }
    n <- n+1 
  }

 print (pos)
  [1] "E"
Run Code Online (Sandbox Code Playgroud)

我很感激任何建议!

r

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

确定$ ARGV [X]是否在perl中传递字符串或文件.

有没有办法,除了检查后缀?或者我应该坚持检查.txt?

perl

-3
推荐指数
1
解决办法
40
查看次数

标签 统计

perl ×2

r ×2

ggplot2 ×1

hash ×1

warnings ×1