小编soo*_*sus的帖子

R:来自multiline ggplot2命令的"一元运算符错误"

我正在使用ggplot2对两种不同物种进行箱线图比较,如下面的第三列所示:

> library(reshape2)
> library(ggplot2)
> melt.data = melt(actb.raw.data)

> head(actb.raw.data)
  region  expression species
1     CG -0.17686667   human
2     CG -0.06506667   human
3     DG  1.04590000   human
4    CA1  1.94093333   human
5    CA2  1.55023333   human
6    CA3  1.75800000   human

> head(melt.data)
  region species   variable       value
1     CG   human expression -0.17686667
2     CG   human expression -0.06506667
3     DG   human expression  1.04590000
4    CA1   human expression  1.94093333
5    CA2   human expression  1.55023333
6    CA3   human expression  1.75800000
Run Code Online (Sandbox Code Playgroud)

但是,当我运行以下代码时:

ggplot(combined.data, aes(x = region, y …
Run Code Online (Sandbox Code Playgroud)

r multiline ggplot2 reshape2

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

条件长度> 1,仅使用第一个元素

我有一个数据帧,旅行:

> head(trip.mutations)
  Ref.y Variant.y
1 T     C 
2 G     C 
3 A     C  
4 T     C 
5 C     A 
6 G     A 
Run Code Online (Sandbox Code Playgroud)

我想添加第三列mutType,遵循以下规则:

for (i in 1:nrow(trip)) {
   if(trip$Ref.y=='G' & trip$Variant.y=='T'|trip$Ref.y=='C' & trip$Variant.y=='A') {
      trip[i, 'mutType'] <- "G:C to T:A"
   }
   else if(trip$Ref.y=='G' & trip$Variant.y=='C'|trip$Ref.y=='C' & trip$Variant.y=='G') {
      trip[i, 'mutType'] <- "G:C to C:G"
   }
   else if(trip$Ref.y=='G' & trip$Variant.y=='A'|trip$Ref.y=='C' & trip$Variant.y=='T') {
      trip[i, 'mutType'] <- "G:C to A:T"
   }
   else if(trip$Ref.y=='A' & trip$Variant.y=='T'|trip$Ref.y=='T' & trip$Variant.y=='A') {
      trip[i, 'mutType'] <- …
Run Code Online (Sandbox Code Playgroud)

conditional if-statement r calculated-columns

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

下载XML和RCurl R软件包时出现"非零退出状态"错误

我有这个问题:

> install.packages("RCurl")
Installing package(s) into ‘/home/username/R/x86_64-redhat-linux-gnu-library/2.13’
(as ‘lib’ is unspecified)
trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/RCurl_1.95-3.tar.gz'
Content type 'application/x-gzip' length 868491 bytes (848 Kb)
opened URL
==================================================
downloaded 848 Kb

* installing *source* package ‘RCurl’ ...
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package ‘RCurl’
* removing ‘/home/username/R/x86_64-redhat-linux-gnu-library/2.13/RCurl’
Warning in install.packages :
  installation of package 'RCurl' had non-zero exit status

The downloaded packages are in
    ‘/tmp/RtmpKyAgF8/downloaded_packages’
Run Code Online (Sandbox Code Playgroud)

和:

> install.packages("XML")
Installing package(s) into ‘/home/username/R/x86_64-redhat-linux-gnu-library/2.13’
(as ‘lib’ is unspecified)
trying …
Run Code Online (Sandbox Code Playgroud)

xml install r package rcurl

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

在R中使用mapply时,将t.test的输出保存到数据帧

我有两个这样的数据帧

a    b    c
1    2    3
2    3    3
1    2    3
Run Code Online (Sandbox Code Playgroud)

具有相同的列名称.我正在使用

mapply(t.test, df1, df2)
Run Code Online (Sandbox Code Playgroud)

输出t.text的结果,比较两个数据帧之间的a,b和c型列.这得到(实际结果):

        LHM                                      
statistic   -11.5671                                 
parameter   90.46322                                 
p.value     1.575918e-19                             
conf.int    Numeric,2                                
estimate    Numeric,2                                
null.value  0                                        
alternative "two.sided"                              
method      "Welch Two Sample t-test"                
data.name   "dots[[1L]][[23L]] and dots[[2L]][[23L]]"
        RaM                                      
statistic   -18.66368                                
parameter   172.2032                                 
p.value     3.200675e-43                             
conf.int    Numeric,2                                
estimate    Numeric,2                                
null.value  0                                        
alternative "two.sided"                              
method      "Welch Two Sample t-test"                
data.name   "dots[[1L]][[24L]] and dots[[2L]][[24L]]"
Run Code Online (Sandbox Code Playgroud)

等等(每个数据帧中有~180列数据).我需要将列的名称及其对应的p值存储在矩阵中.将哪个数据框包含较高值存储在另一列中也是有帮助的.救命?

statistics r

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

在单行Perl中打印反向DNA补体

我想写一个快速的单行perl脚本来产生DNA序列的反向互补.但是,以下内容对我不起作用:

$ cat sample.dna.sequence.txt | perl -ne '{while (<>) {$seq = $_; $seq =~ tr /atcgATCG/tagcTAGC/; $revComp = reverse($seq); print $revComp;}}'
Run Code Online (Sandbox Code Playgroud)

有什么建议?我知道

tr -d "\n " < input.txt | tr "[ATGCatgcNn]" "[TACGtacgNn]" | rev
Run Code Online (Sandbox Code Playgroud)

在bash中工作,但是我想用perl来做这个练习.

bash perl sequence

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

根据条件匹配R中多列中的值

说我有一个数据名人堂 df

resident    faculty    submittedBy    match    caseID    phase

george      sally      george         1        george_1  pre
george      sally      sally          0        george_1  pre
george      sally      george         1        george_1  intra
jane        carl       jane           1        jane_1    pre
jane        carl       carl           0        jane_1    pre
jane        carl       carl           0        jane_1    intra
Run Code Online (Sandbox Code Playgroud)

并且我想df$response根据以下参数在此数据框中添加一列(我认为我需要一组嵌套的ifelses,但是我正在努力正确地执行它):

对于给定的X行,如果df$match= 1,

在以下情况下打印“ 1” df$response

任何行df$match,其中df$match= 0具有在相同的内容df$caseIDdf$faculty以及df$phase作为列X.否则打印“0”。

所以输出应该是这样的:

response

1
0
0
1
0
0
Run Code Online (Sandbox Code Playgroud)

因为只有第一和第四行包含值,其中有在比赛df$caseIDdf$faculty …

if-statement r string-matching

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