我的NANOVA.test代码有什么问题?

时间:2014-10-26 20:37:46

标签: r

我有一个数据集我试图使用TANOVA包中的NANOVA.test,我不断收到如下错误:

> NANOVA.test(thesisdata$Survivors,Fungus,Phosphite)
**Error in matrix(nrow = dim(data)[1], ncol = dim(data)[2]) : 
  non-numeric matrix extent**


> f2<c(0,0.75,1.5,3.0,6.0,12.0,0,0.75,1.5,3.0,6.0,12.0)
**Error: object 'f2' not found**
> f2<-c(0,0.75,1.5,3.0,6.0,12.0,0,0.75,1.5,3.0,6.0,12.0)
> NANOVA.test(data,f1,f2)
**Error: object 'v' not found**
> > NANOVA.test(data,f1,f2)
**Error in data[, ix] : subscript out of bounds**
> f1<-factor(f1)
> f2<-factor(f2)
> NANOVA.test(data,f1,f2)
**Error in data[, ix] : subscript out of bounds**

链接到来源 - http://freesourcecode.net/rprojects/4638/sourcecode/NANOVA.test.R#.VErsT_ldW7k

链接到代码说明 - http://cran.r-project.org/web/packages/TANOVA/TANOVA.pdf

我似乎无法让它发挥作用:(

编辑:

以下是我正在尝试的内容,我已经完成了几次迭代并试图让这个功能起作用。

> thesisdata=read.table(file="C:/Users/User/Desktop/data thesis stuff/ThesisConsolidatedSurvivorData.txt",header=TRUE)
> # The data was checked to load correctly
> thesisdata
   ID Letter Number Survivors   Fungus Phosphite
1  A1      A      1         2 0.069281      0.00
2  A2      A      2         4 0.069281      0.00
3  A3      A      3         5 0.069281      0.00
4  A4      A      4         5 0.069281      0.00
5  B1      B      1         5 0.069281      0.75
6  B2      B      2         1 0.069281      0.75
7  B3      B      3         2 0.069281      0.75
8  B4      B      4         4 0.069281      0.75
9  C1      C      1         4 0.069281      1.50
10 C2      C      2         2 0.069281      1.50
11 C3      C      3         3 0.069281      1.50
12 C4      C      4         4 0.069281      1.50
13 D1      D      1         2 0.069281      3.00
14 D2      D      2         4 0.069281      3.00
15 D3      D      3         4 0.069281      3.00
16 D4      D      4         5 0.069281      3.00
17 E1      E      1         4 0.069281      6.00
18 E2      E      2         4 0.069281      6.00
19 E3      E      3         3 0.069281      6.00
20 E4      E      4         3 0.069281      6.00
21 F1      F      1         3 0.069281     12.00
22 F2      F      2         4 0.069281     12.00
23 F3      F      3         2 0.069281     12.00
24 F4      F      4         2 0.069281     12.00
25 G1      G      1         2 0.000000      0.00
26 G2      G      2         2 0.000000      0.00
27 G3      G      3         4 0.000000      0.00
28 G4      G      4         3 0.000000      0.00
29 H1      H      1         2 0.000000      0.75
30 H2      H      2         2 0.000000      0.75
31 H3      H      3         3 0.000000      0.75
32 H4      H      4         4 0.000000      0.75
33 I1      I      1         2 0.000000      1.50
34 I2      I      2         3 0.000000      1.50
35 I3      I      3         3 0.000000      1.50
36 I4      I      4         3 0.000000      1.50
37 J1      J      1         3 0.000000      3.00
38 J2      J      2         3 0.000000      3.00
39 J3      J      3         3 0.000000      3.00
40 J4      J      4         3 0.000000      3.00
41 K1      K      1         3 0.000000      6.00
42 K2      K      2         1 0.000000      6.00
43 K3      K      3         3 0.000000      6.00
44 K4      K      4         2 0.000000      6.00
45 L1      L      1         1 0.000000     12.00
46 L2      L      2         3 0.000000     12.00
47 L3      L      3         0 0.000000     12.00
48 L4      L      4         1 0.000000     12.00
> # The data appeared to load correctly
> attach(thesisdata)
The following objects are masked from thesisdata (pos = 5):

    Fungus, ID, Letter, Number, Phosphite, Survivors

The following objects are masked from thesisdata (pos = 7):

    Fungus, ID, Letter, Number, Phosphite, Survivors

> Fungus
 [1] 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281
 [9] 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281
[17] 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281 0.069281
[25] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[33] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[41] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
> ID
 [1] A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 E1 E2 E3 E4 F1 F2 F3 F4 G1
[26] G2 G3 G4 H1 H2 H3 H4 I1 I2 I3 I4 J1 J2 J3 J4 K1 K2 K3 K4 L1 L2 L3 L4
48 Levels: A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4 E1 E2 E3 E4 ... L4
> Letter
 [1] A A A A B B B B C C C C D D D D E E E E F F F F G G G G H H H H I I I I J J
[39] J J K K K K L L L L
Levels: A B C D E F G H I J K L
> Number
 [1] 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2
[39] 3 4 1 2 3 4 1 2 3 4
> Phosphite
 [1]  0.00  0.00  0.00  0.00  0.75  0.75  0.75  0.75  1.50  1.50  1.50  1.50
[13]  3.00  3.00  3.00  3.00  6.00  6.00  6.00  6.00 12.00 12.00 12.00 12.00
[25]  0.00  0.00  0.00  0.00  0.75  0.75  0.75  0.75  1.50  1.50  1.50  1.50
[37]  3.00  3.00  3.00  3.00  6.00  6.00  6.00  6.00 12.00 12.00 12.00 12.00
> Survivors
 [1] 2 4 5 5 5 1 2 4 4 2 3 4 2 4 4 5 4 4 3 3 3 4 2 2 2 2 4 3 2 2 3 4 2 3 3 3 3 3
[39] 3 3 3 1 3 2 1 3 0 1
> datum<-martix(Survivors,Number,Letter)
Error: could not find function "martix"
> datum<-matrix(Survivors,Number,Letter)
Error in matrix(Survivors, Number, Letter) : non-numeric matrix extent
> datum<-matrix(Survivors,Phosphite,Fungus)
Warning message:
In matrix(Survivors, Phosphite, Fungus) :
  data length exceeds size of matrix
> Survivor
Error: object 'Survivor' not found
> thesisdata
   ID Letter Number Survivors   Fungus Phosphite
1  A1      A      1         2 0.069281      0.00
2  A2      A      2         4 0.069281      0.00
3  A3      A      3         5 0.069281      0.00
4  A4      A      4         5 0.069281      0.00
5  B1      B      1         5 0.069281      0.75
6  B2      B      2         1 0.069281      0.75
7  B3      B      3         2 0.069281      0.75
8  B4      B      4         4 0.069281      0.75
9  C1      C      1         4 0.069281      1.50
10 C2      C      2         2 0.069281      1.50
11 C3      C      3         3 0.069281      1.50
12 C4      C      4         4 0.069281      1.50
13 D1      D      1         2 0.069281      3.00
14 D2      D      2         4 0.069281      3.00
15 D3      D      3         4 0.069281      3.00
16 D4      D      4         5 0.069281      3.00
17 E1      E      1         4 0.069281      6.00
18 E2      E      2         4 0.069281      6.00
19 E3      E      3         3 0.069281      6.00
20 E4      E      4         3 0.069281      6.00
21 F1      F      1         3 0.069281     12.00
22 F2      F      2         4 0.069281     12.00
23 F3      F      3         2 0.069281     12.00
24 F4      F      4         2 0.069281     12.00
25 G1      G      1         2 0.000000      0.00
26 G2      G      2         2 0.000000      0.00
27 G3      G      3         4 0.000000      0.00
28 G4      G      4         3 0.000000      0.00
29 H1      H      1         2 0.000000      0.75
30 H2      H      2         2 0.000000      0.75
31 H3      H      3         3 0.000000      0.75
32 H4      H      4         4 0.000000      0.75
33 I1      I      1         2 0.000000      1.50
34 I2      I      2         3 0.000000      1.50
35 I3      I      3         3 0.000000      1.50
36 I4      I      4         3 0.000000      1.50
37 J1      J      1         3 0.000000      3.00
38 J2      J      2         3 0.000000      3.00
39 J3      J      3         3 0.000000      3.00
40 J4      J      4         3 0.000000      3.00
41 K1      K      1         3 0.000000      6.00
42 K2      K      2         1 0.000000      6.00
43 K3      K      3         3 0.000000      6.00
44 K4      K      4         2 0.000000      6.00
45 L1      L      1         1 0.000000     12.00
46 L2      L      2         3 0.000000     12.00
47 L3      L      3         0 0.000000     12.00
48 L4      L      4         1 0.000000     12.00
> NANOVA.test(thesisdata$Survivors,Fungus,Phosphite)
Error in matrix(nrow = dim(data)[1], ncol = dim(data)[2]) : 
  non-numeric matrix extent
> datum<-matrix(Survivors,4,6)
> datum
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    2    5    4    2    4    3
[2,]    4    1    2    4    4    4
[3,]    5    2    3    4    3    2
[4,]    5    4    4    5    3    2
> t(datum)
     [,1] [,2] [,3] [,4]
[1,]    2    4    5    5
[2,]    5    1    2    4
[3,]    4    2    3    4
[4,]    2    4    4    5
[5,]    4    4    3    3
[6,]    3    4    2    2
> datum<-t(datum)
> datum<-matrix(Survivors,4,12)
> datum<-t(datum)
> datum
      [,1] [,2] [,3] [,4]
 [1,]    2    4    5    5
 [2,]    5    1    2    4
 [3,]    4    2    3    4
 [4,]    2    4    4    5
 [5,]    4    4    3    3
 [6,]    3    4    2    2
 [7,]    2    2    4    3
 [8,]    2    2    3    4
 [9,]    2    3    3    3
[10,]    3    3    3    3
[11,]    3    1    3    2
[12,]    1    3    0    1
> data<-datum
> data
      [,1] [,2] [,3] [,4]
 [1,]    2    4    5    5
 [2,]    5    1    2    4
 [3,]    4    2    3    4
 [4,]    2    4    4    5
 [5,]    4    4    3    3
 [6,]    3    4    2    2
 [7,]    2    2    4    3
 [8,]    2    2    3    4
 [9,]    2    3    3    3
[10,]    3    3    3    3
[11,]    3    1    3    2
[12,]    1    3    0    1
> f1<-c(nospore,nospore,nospore,nospore,nospore,nospore,spore,spore,spore,spore,spore,spore)
Error: object 'nospore' not found
> f1<-c(0,0,0,0,0,0,0.069281,0.069281,0.069281,0.069281,0.069281,0.069281)
> f2<c(0,0.75,1.5,3.0,6.0,12.0,0,0.75,1.5,3.0,6.0,12.0)
Error: object 'f2' not found
> f2<-c(0,0.75,1.5,3.0,6.0,12.0,0,0.75,1.5,3.0,6.0,12.0)
> NANOVA.test(data,f1,f2)
Error: object 'v' not found
> 
> NANOVA.test(data,4,12)
Error: object 'v' not found
> NANOVA.test(data,12,4)
Error: object 'v' not found
> f1<-c(1,2,3,4)
> f2<-c(1,2,3,4,5,6,7,8,9,10,11,12)
> NANOVA.test(data,f1,f2)
Error in data[, ix] : subscript out of bounds
> f1<-factor(f1)
> f2<-factor(f2)
> NANOVA.test(data,f1,f2)
Error in data[, ix] : subscript out of bounds
> 

试图通过'亚磷酸盐'和'真菌'引导'幸存者'

在尝试制作矩阵后出现了一些错误,但无论我尝试什么,我似乎无法让它工作。

编辑:根据建议我尝试不附加

> NANOVA.test(thesisdata$Survivors,thesisdata$Fungus,thesisdata$Phosphite,type=2,B=100, robustify=FALSE,equal.size=FALSE,eb=FALSE)
Error in matrix(nrow = dim(data)[1], ncol = dim(data)[2]) : 
  non-numeric matrix extent

所以我重新格式化了数据表,只包括'幸存者''亚磷酸盐'和'真菌'和R吐出

> NANOVA.test(thesisdata$Survivors,thesisdata$Fungus,thesisdata$Phosphite,type=2,B=100, robustify=FALSE,equal.size=FALSE,eb=FALSE)
Error in sort.list(x, decreasing = decreasing) : 
  argument 1 is not a vector
In addition: Warning message:
In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'

我不确定这是否有进展但我仍然在搞乱。

编辑:

不得不在亚磷酸盐中使P浓缩...

> NANOVA.test(thesisdata$Survivors,thesisdata$Fungus,thesisdata$phosphite,type=2,B=100, robustify=FALSE,equal.size=FALSE,eb=FALSE)
Error in matrix(nrow = dim(data)[1], ncol = dim(data)[2]) : 
  non-numeric matrix extent

回到这里

编辑:继续我制作一个矩阵来处理这个

 Surmatrix <- matrix(thesisdata$Survivors,12,4)
> Surmatrix
      [,1] [,2] [,3] [,4]
 [1,]    2    2    2    3
 [2,]    4    4    2    3
 [3,]    5    4    4    3
 [4,]    5    5    3    3
 [5,]    5    4    2    3
 [6,]    1    4    2    1
 [7,]    2    3    3    3
 [8,]    4    3    4    2
 [9,]    4    3    2    1
[10,]    2    4    3    3
[11,]    3    2    3    0
[12,]    4    2    3    1
> NANOVA.test(Surmatrix,thesisdata$Fungus,thesisdata$phosphite,type=2,B=100, robustify=FALSE,equal.size=FALSE,eb=FALSE)
Error: object 'v' not found

,它从之前的

回到了这个错误

0 个答案:

没有答案