错误:参数1不是向量

时间:2017-05-26 12:16:31

标签: r

我正在按照Rhea脚本分析微生物测序数据。最后一个命令给我错误说"

  

参数1不是向量

虽然我已经密切关注了剧本。

查找下面附带的会话信息。

`R version 3.4.0 (2017-04-21) -- "You Stupid Darkness"
 Copyright (C) 2017 The R Foundation for Statistical Computing
 Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> setwd("C:/Users/Jonas/Desktop/Bielefeld")
> file_name<- "C:/Users/Jonas/Desktop/Bielefeld/OTUs_Table-norm.tab"
> Species.richness <- function(x)
+ {
+    
+     count=sum(x[x>0.5]^0)
+     return(count)
+ }
> Shannon.entropy <- function(x)
+ {
+     total=sum(x)
+     se=-sum(x[x>0]/total*log(x[x>0]/total))
+     return(se)
+ }
> Shannon.effective <- function(x)
+ {
+     total=sum(x)
+     se=round(exp(-sum(x[x>0]/total*log(x[x>0]/total))),digits =2)
+     return(se)
+ }
> Simpson.concentration <- function(x)
+ {
+     total=sum(x)
+     si=sum((x[x>0]/total)^2)
+     return(si)
+ }
> Simpson.effective <- function(x)
+ {
+     total=sum(x)
+     si=round(1/sum((x[x>0]/total)^2),digits =2)
+     return(si)
+ }
> otu_table <- read.table (file_name, 
+                          check.names = FALSE, 
+                          header=TRUE, 
+                          dec=".", 
+                          sep = "\t",
+                          row.names = 1)
> otu_table <- otu_table[!apply(is.na(otu_table) | otu_table=="",1,all),]
> 
> my_otu_table <- otu_table[,order(names(otu_table))] 
Error in order(names(otu_table)) : argument 1 is not a vector
> my_otu_table <-data.frame(t(my_otu_table))
Error in t(my_otu_table) : object 'my_otu_table' not found`





'> str(otu_table)
'data.frame':   166 obs. of  1 variable:
$ Sample1: int  102243 48415 5602 9142 1560 1099 1153 1088 1891 414 ...
> otu_table <- otu_table[!apply(is.na(otu_table) | otu_table=="",1,all),]
> 
> str(otu_table)
 int [1:166] 102243 48415 5602 9142 1560 1099 1153 1088 1891 414 ...
> 





> otu_table[!is.na(otu_table)]
[1] 102243  48415   5602   9142   1560   1099   1153   1088   1891    414    
526    504    612    795    568
 [16]    459    680    212    207    265    156    149    149    228    327    
212    114    666    296    751
 [31]     37    272    220    851    126    162    250    122    124    431    
118    221    141    153     83
 [46]     51    149    256    166    120    158     11    116     84    291    
130    371    138    129     58
 [61]     98    176     86     69    192     27     59     31     61     35     
58    110     46    105    153
 [76]     87      6    119     31    100     84     61      9     60    201    
101     68      4    439     46
 [91]     59     35     61     97     11     16    167    101     46    127     
16    101    144      8     65
[106]     55     51     39     48      6     93      2      2     37     24     
15     15     24     52      3
[121]      2      2     27     13      2      2    131     10     32      5     
49     41      2     56     83
[136]      2     11     77     75     20      5     33     95     57      4      
7     24     57     27     19
[151]     55      2      4    693     15      2      3     12     19      8      
4    108     72     12      5
[166]      2
> my_otu_table <- otu_table[order(names(otu_table))] 
Error in order(names(otu_table)) : argument 1 is not a vector
> my_otu_table <-data.frame(t(my_otu_table))
Error in t(my_otu_table) : object 'my_otu_table' not found'

0 个答案:

没有答案