R Studio-'qr'和'y'必须具有相同的行数

时间:2019-02-22 13:29:27

标签: r dataframe difference median

我正在尝试测试我正在使用的两个栖息地的每个订单的中位丰度之间是否存在差异,但这给了我一个错误:

Error in qr.fitted(qrhs, G) : 
  'qr' and 'y' must have the same number of rows

这是控制台输出:

> #load packages
> library('vegan')
> library('dplyr')
> #set working directory
> setwd('C:/Users/melan/OneDrive/Documents/Year 3/Dissertation/R Studio')
> #Read in Csvs
> dat<-read.csv ('SKOMER_2018_Species_List_Abundance.csv')
> dat2<-read.csv('Species and Abundance.csv')
> #create data to link in environmental factors
> datenv <-
+   dat %>%
+   group_by(Video) %>%
+   summarise(habitat=unique(Sediment),
+             date=unique(Date),
+             time=unique(Time),
+             tide=unique(Tide),
+             depth=unique(Depth),
+             visit=unique(Visit),
+             order=unique(order))%>% arrange(order)
> #PERMANOVA 2 - MEDIANS
> ord<-read.csv('Order2.csv')
> head(ord)
            Name Order X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19
1   Malacostraca   MAL 11 10  9  7  5 11 11  8  6   5   9   7   3   7   3   2   4   6   1   2   4
2 Actinopterygii   ACT 11  5  4  3  2  2  5  6  5   6  51  15   2   5   3  37   5   5   2   3   0
3     Polychaeta   POL  0  0  0  1  0  2  1  2  3   0   0   0   0   0   0   0   0   0   0   0   0
4       Bivaliva   BIV  0  0  0  0  0  1  1  0  0   0   0   0   2   0   1   0   0   0   0   3   0
5  Chondrichthys   CHO  0  0  0  0  0  0  0  1  0   0   3   3   0   0   0   0   0   0   0   0   0
6    gastropodoa   GAS  3  4 10  6  6  6 14  2  6  14   1   2   0   0   8   2   0   6   4   2   1
> #flip table 
> ord2<- t((ord[,3:ncol(ord)]))
> dimnames(ord2)[[2]]<-ord$Order
> head(ord2)
   MAL ACT POL BIV CHO GAS OPH TEN
X1  11  11   0   0   0   3   0   3
X2  10   5   0   0   0   4   0   0
X3   9   4   0   0   0  10   0   0
X4   7   3   1   0   0   6   0   0
X5   5   2   0   0   0   6   0   0
X6  11   2   2   1   0   6   0   0
> mod3<-adonis2(ord2~habitat, data=datenv)
Error in qr.fitted(qrhs, G) : 
  'qr' and 'y' must have the same number of rows
> (mod3)
Error: object 'mod3' not found

我知道这可能不足以解决问题,但是我对这个程序没有太多的经验。我将非常感谢您的帮助,如果可以提供其他任何信息,请告诉我。

谢谢

0 个答案:

没有答案