library (vegan)
## Carregando pacotes exigidos: permute
## Carregando pacotes exigidos: lattice
## This is vegan 2.6-4
library(BiodiversityR)
## Carregando pacotes exigidos: tcltk
## BiodiversityR 2.15-1: Use command BiodiversityRGUI() to launch the Graphical User Interface; 
## to see changes use BiodiversityRGUI(changeLog=TRUE, backward.compatibility.messages=TRUE)
data (BCI)
dim(BCI) # Foram plotas 50 linhas com 225colunas. que representa respectivamente 1h e as éspecies de arvorés 
## [1]  50 225
specnumber(BCI) # foi usado o pacote "vegan"
##   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
##  93  84  90  94 101  85  82  88  90  94  87  84  93  98  93  93  93  89 109 100 
##  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40 
##  99  91  99  95 105  91  99  85  86  97  77  88  86  92  83  92  88  82  84  80 
##  41  42  43  44  45  46  47  48  49  50 
## 102  87  86  81  81  86 102  91  91  93
rowSums(BCI)
##   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
## 448 435 463 508 505 412 416 431 409 483 401 366 409 438 462 437 381 347 433 429 
##  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40 
## 408 418 340 392 442 407 417 387 364 475 421 459 436 447 601 430 435 447 424 489 
##  41  42  43  44  45  46  47  48  49  50 
## 402 414 407 409 444 430 425 415 427 432
(colSums(BCI)) #  é visto a tabela inteira das éspecies 
##               Abarema.macradenia            Vachellia.melanoceras 
##                                1                                3 
##            Acalypha.diversifolia            Acalypha.macrostachya 
##                                2                                1 
##                   Adelia.triloba             Aegiphila.panamensis 
##                               92                               23 
##          Alchornea.costaricensis              Alchornea.latifolia 
##                              156                                1 
##                 Alibertia.edulis          Allophylus.psilospermus 
##                                1                               27 
##                 Alseis.blackiana                Amaioua.corymbosa 
##                              983                                3 
##              Anacardium.excelsum                   Andira.inermis 
##                               22                               28 
##                  Annona.spraguei                    Apeiba.glabra 
##                               27                              236 
##                 Apeiba.tibourbou          Aspidosperma.desmanthum 
##                               21                               52 
##         Astrocaryum.standleyanum             Astronium.graveolens 
##                              201                               39 
##                Attalea.butyracea                Banara.guianensis 
##                               33                                1 
##            Beilschmiedia.pendula              Brosimum.alicastrum 
##                              294                              188 
##               Brosimum.guianense          Calophyllum.longifolium 
##                                1                               55 
##                Casearia.aculeata                 Casearia.arborea 
##                               23                              100 
##           Casearia.commersoniana              Casearia.guianensis 
##                                3                                2 
##              Casearia.sylvestris           Cassipourea.guianensis 
##                               54                               87 
##        Cavanillesia.platanifolia                Cecropia.insignis 
##                               19                              264 
##             Cecropia.obtusifolia                  Cedrela.odorata 
##                               25                                2 
##                  Ceiba.pentandra                  Celtis.schippii 
##                               39                               38 
##            Cespedesia.spathulata               Chamguava.schippii 
##                                2                                3 
##            Chimarrhis.parviflora                Maclura.tinctoria 
##                                1                                1 
##            Chrysochlamys.eclipes          Chrysophyllum.argenteum 
##                                2                               85 
##            Chrysophyllum.cainito               Coccoloba.coronata 
##                               25                               22 
##         Coccoloba.manzinellensis             Colubrina.glandulosa 
##                               13                                1 
##                 Cordia.alliodora                   Cordia.bicolor 
##                               63                              325 
##                Cordia.lasiocalyx             Coussarea.curvigemma 
##                              364                               55 
##             Croton.billbergianus                  Cupania.cinerea 
##                               98                                1 
##                Cupania.latifolia                Cupania.rufescens 
##                               12                                4 
##                Cupania.seemannii             Dendropanax.arboreus 
##                               47                               88 
##             Desmopsis.panamensis          Diospyros.artanthifolia 
##                               13                               16 
##                Dipteryx.oleifera               Drypetes.standleyi 
##                               33                              285 
##                  Elaeis.oleifera        Enterolobium.schomburgkii 
##                               21                                2 
##          Erythrina.costaricensis        Erythroxylum.macrophyllum 
##                               26                               18 
##                  Eugenia.florida             Eugenia.galalonensis 
##                               81                               12 
##                Eugenia.nesiotica              Eugenia.oerstediana 
##                               55                              177 
##             Faramea.occidentalis                 Ficus.colubrinae 
##                             1717                                1 
##                Ficus.costaricana                   Ficus.insipida 
##                                7                                3 
##                     Ficus.maxima                Ficus.obtusifolia 
##                                4                                7 
##                   Ficus.popenoei                   Ficus.tonduzii 
##                                3                               23 
##                  Ficus.trigonata                 Ficus.yoponensis 
##                                5                                6 
##              Garcinia.intermedia                 Garcinia.madruno 
##                               92                               12 
##                 Genipa.americana               Guapira.myrtiflora 
##                               23                               99 
##                     Guarea.fuzzy               Guarea.grandifolia 
##                               68                               10 
##                  Guarea.guidonia              Guatteria.dumetorum 
##                              376                              244 
##                Guazuma.ulmifolia               Guettarda.foliacea 
##                               38                               85 
##                 Gustavia.superba             Hampea.appendiculata 
##                              644                               13 
##             Hasseltia.floribunda              Heisteria.acuminata 
##                              229                                7 
##               Heisteria.concinna               Hirtella.americana 
##                              288                                5 
##                Hirtella.triandra                   Hura.crepitans 
##                              681                              101 
##          Hieronyma.alchorneoides                   Inga.acuminata 
##                               41                               26 
##                  Inga.cocleensis                   Inga.goldmanii 
##                               52                               49 
##                     Inga.laurina                   Inga.semialata 
##                               10                               98 
##                     Inga.nobilis                 Inga.oerstediana 
##                               67                                2 
##                  Inga.pezizifera                    Inga.punctata 
##                               20                               10 
##                    Inga.ruiziana                 Inga.sapindoides 
##                                5                               76 
##                 Inga.spectabilis                 Inga.umbellifera 
##                               14                               14 
##                 Jacaranda.copaia             Lacistema.aggregatum 
##                              236                               33 
##             Lacmellea.panamensis                   Laetia.procera 
##                               51                               12 
##                   Laetia.thamnia            Lafoensia.punicifolia 
##                               27                                5 
##                Licania.hypoleuca                 Licania.platypus 
##                               14                               10 
##              Lindackeria.laurina        Lonchocarpus.heptaphyllus 
##                               64                              121 
##                 Luehea.seemannii               Macrocnemum.roseum 
##                               93                               25 
##   Maquira.guianensis.costaricana             Margaritaria.nobilis 
##                              167                                2 
##                 Marila.laxiflora                Maytenus.schippii 
##                               10                               21 
##                  Miconia.affinis                 Miconia.argentea 
##                                8                               70 
##                    Miconia.elata              Miconia.hondurensis 
##                                1                                7 
##              Mosannona.garwoodii                Myrcia.gatunensis 
##                               15                                5 
##           Myrospermum.frutescens             Nectandra.cissiflora 
##                                7                               33 
##                Nectandra.lineata               Nectandra.purpurea 
##                               10                                4 
##               Ochroma.pyramidale                    Ocotea.cernua 
##                                5                               29 
##                   Ocotea.oblonga                  Ocotea.puberula 
##                               36                               22 
##                    Ocotea.whitei                Oenocarpus.mapora 
##                              184                              788 
##                Ormosia.amazonica                 Ormosia.coccinea 
##                                1                                5 
##               Ormosia.macrocalyx                  Pachira.quinata 
##                                3                                1 
##                 Pachira.sessilis              Perebea.xanthochyma 
##                                9                               21 
##           Cinnamomum.triplinerve              Picramnia.latifolia 
##                               16                               45 
##                Piper.reticulatum            Platymiscium.pinnatum 
##                                9                               61 
##              Platypodium.elegans             Posoqueria.latifolia 
##                               43                               15 
##                 Poulsenia.armata                 Pourouma.bicolor 
##                              755                               13 
##               Pouteria.fossicola              Pouteria.reticulata 
##                                2                              203 
##               Pouteria.stipitata                Prioria.copaifera 
##                               31                              345 
##             Protium.costaricense                Protium.panamense 
##                              111                               50 
##              Protium.tenuifolium          Pseudobombax.septenatum 
##                              381                                8 
##      Psidium.friedrichsthalianum               Psychotria.grandis 
##                                4                                2 
##               Pterocarpus.rohrii           Quararibea.asterolepis 
##                               80                              724 
##                    Quassia.amara                    Randia.armata 
##                                4                              248 
##                 Sapium.broadleaf               Sapium.glandulosum 
##                                3                               17 
##            Schizolobium.parahyba                  Senna.dariensis 
##                                2                                1 
##                  Simarouba.amara              Siparuna.guianensis 
##                              289                               13 
##              Siparuna.pauciflora               Sloanea.terniflora 
##                               16                               78 
##               Socratea.exorrhiza                  Solanum.hayesii 
##                              346                               12 
##                  Sorocea.affinis              Spachea.membranacea 
##                               28                                8 
##                  Spondias.mombin              Spondias.radlkoferi 
##                               29                               63 
##                Sterculia.apetala Swartzia.simplex.var.grandiflora 
##                               26                              218 
##   Swartzia.simplex.continentalis            Symphonia.globulifera 
##                              118                               26 
##            Handroanthus.guayacan                   Tabebuia.rosea 
##                               30                               68 
##          Tabernaemontana.arborea             Tachigali.versicolor 
##                              322                               98 
##                  Talisia.nervosa                 Talisia.princeps 
##                                1                                3 
##              Terminalia.amazonia               Terminalia.oblonga 
##                               28                               43 
##          Tetragastris.panamensis        Tetrathylacium.johansenii 
##                              379                                7 
##                  Theobroma.cacao                  Thevetia.ahouai 
##                               12                                2 
##                Tocoyena.pittieri             Trattinnickia.aspera 
##                                5                               40 
##                  Trema.micrantha            Trichanthera.gigantea 
##                               15                                2 
##                Trichilia.pallida            Trichilia.tuberculata 
##                               82                             1681 
##          Trichospermum.galeottii             Triplaris.cumingiana 
##                                1                              147 
##                  Trophis.caucana                 Trophis.racemosa 
##                               33                               32 
##            Turpinia.occidentalis               Unonopsis.pittieri 
##                               58                              163 
##                Virola.multiflora                  Virola.sebifera 
##                               25                              617 
##              Virola.surinamensis                 Vismia.baccifera 
##                              164                                1 
##              Vochysia.ferruginea                Xylopia.macrantha 
##                               12                              143 
##              Zanthoxylum.ekmanii          Zanthoxylum.juniperinum 
##                              149                               45 
##            Zanthoxylum.panamense            Zanthoxylum.setulosum 
##                               67                                1 
##                Zuelania.guidonia 
##                               10
sp1<-specaccum(BCI, "random")
sp1
## Species Accumulation Curve
## Accumulation method: random, with 100 permutations
## Call: specaccum(comm = BCI, method = "random") 
## 
##                                                                             
## Sites     1.00000   2.00000   3.0000   4.00000   5.00000   6.00000   7.00000
## Richness 91.08000 121.13000 139.7100 151.32000 159.61000 165.86000 171.23000
## sd        7.30806   7.09767   6.5417   6.49146   5.98296   5.22237   5.26443
##                                                                              
## Sites      8.00000   9.0000  10.00000  11.00000  12.00000  13.00000  14.00000
## Richness 175.71000 179.2700 182.75000 185.50000 188.31000 190.34000 192.16000
## sd         5.06382   5.1323   4.91622   4.69795   4.66167   4.54877   4.58086
##                                                                               
## Sites     15.00000  16.00000  17.00000  18.00000  19.00000  20.00000  21.00000
## Richness 194.27000 196.10000 198.01000 199.69000 201.18000 202.41000 203.80000
## sd         4.40352   4.46875   4.52935   4.42147   4.12526   4.16356   4.26401
##                                                                             
## Sites     22.00000  23.00000  24.00000  25.0000  26.00000  27.0000  28.00000
## Richness 205.12000 206.32000 207.43000 208.6600 209.69000 210.4300 211.35000
## sd         4.02085   4.27792   4.00064   3.9086   3.84733   3.7234   3.41232
##                                                                               
## Sites     29.00000  30.00000  31.00000  32.00000  33.00000  34.00000  35.00000
## Richness 212.20000 213.15000 213.90000 214.76000 215.45000 216.12000 216.84000
## sd         3.14627   2.99284   3.02348   2.84665   2.77206   2.64491   2.61588
##                                                                               
## Sites     36.00000  37.00000  38.00000  39.00000  40.00000  41.00000  42.00000
## Richness 217.46000 218.22000 218.82000 219.49000 220.27000 220.95000 221.56000
## sd         2.40547   2.47239   2.31106   2.29402   2.13605   2.12429   1.92967
##                                                                             
## Sites     43.00000  44.0000  45.00000  46.00000  47.0000  48.00000  49.00000
## Richness 222.02000 222.6800 223.13000 223.57000 223.9600 224.36000 224.71000
## sd         1.79213   1.6629   1.49514   1.32005   1.1885   0.91585   0.53739
##             
## Sites     50
## Richness 225
## sd         0
plot(sp1, ci.type="poly", col="green", lwd=2, ci.lty=0, ci.col="lightblue")
boxplot(sp1, col="yellow", add=TRUE, pch="+")

mod <- rad.lognormal(BCI[5,])
mod
## 
## RAD model: Log-Normal 
## Family: poisson 
## No. of species:  101 
## Total abundance: 505 
## 
##     log.mu  log.sigma   Deviance        AIC        BIC 
##   0.951926   1.165929  17.077549 317.656487 322.886728
plot(mod)

mod2 <- radfit(BCI[1,])
mod2
## 
## RAD models, family poisson 
## No. of species 93, total abundance 448
## 
##            par1      par2     par3    Deviance AIC      BIC     
## Null                                   39.5261 315.4362 315.4362
## Preemption  0.042797                   21.8939 299.8041 302.3367
## Lognormal   1.0687    1.0186           25.1528 305.0629 310.1281
## Zipf        0.11033  -0.74705          61.0465 340.9567 346.0219
## Mandelbrot  100.52   -2.312    24.084   4.2271 286.1372 293.7350
plot(mod2)

data(dune)
data("dune.env")
bio<-rankabuncomp(dune, dune.env, factor='Management', return.data=TRUE, specnames=c(1:2), legend=FALSE)

bio
##    Grouping  species labelit rank abundance proportion plower pupper accumfreq
## 1        BF Lolipere    TRUE    1        18       15.4    3.6   27.2      15.4
## 2        BF Trifrepe    TRUE    2        14       12.0    6.6   17.3      27.4
## 3        BF Scorautu   FALSE    3        13       11.1    0.7   21.5      38.5
## 4        BF  Poaprat   FALSE    4        12       10.3    6.3   14.2      48.7
## 5        BF  Poatriv   FALSE    5        11        9.4   -9.9   28.7      58.1
## 6        BF Bromhord   FALSE    6         8        6.8   -5.2   18.9      65.0
## 7        BF Achimill   FALSE    7         7        6.0   -5.0   17.0      70.9
## 8        BF Planlanc   FALSE    8         6        5.1   -6.9   17.1      76.1
## 9        BF Bracruta   FALSE    9         6        5.1   -9.3   19.5      81.2
## 10       BF Bellpere   FALSE   10         5        4.3   -4.0   12.5      85.5
## 11       BF Anthodor   FALSE   11         4        3.4  -10.6   17.4      88.9
## 12       BF Elymrepe   FALSE   12         4        3.4  -10.8   17.6      92.3
## 13       BF Vicilath   FALSE   13         3        2.6   -4.6    9.8      94.9
## 14       BF Alopgeni   FALSE   14         2        1.7   -5.4    8.8      96.6
## 15       BF Hyporadi   FALSE   15         2        1.7   -6.3    9.7      98.3
## 16       BF Sagiproc   FALSE   16         2        1.7   -6.3    9.7     100.0
## 17       HF  Poatriv    TRUE    1        24       11.3    8.4   14.1      11.3
## 18       HF Lolipere    TRUE    2        20        9.4    3.7   15.1      20.7
## 19       HF  Poaprat   FALSE    3        17        8.0    4.9   11.1      28.6
## 20       HF Rumeacet   FALSE    4        16        7.5    1.1   13.9      36.2
## 21       HF Planlanc   FALSE    5        15        7.0   -0.7   14.7      43.2
## 22       HF Scorautu   FALSE    6        14        6.6    5.2    8.0      49.8
## 23       HF Trifrepe   FALSE    7        14        6.6    3.3    9.8      56.3
## 24       HF Bracruta   FALSE    8        14        6.6    1.9   11.2      62.9
## 25       HF Elymrepe   FALSE    9        10        4.7   -3.6   13.0      67.6
## 26       HF Anthodor   FALSE   10         9        4.2   -0.8    9.2      71.8
## 27       HF Trifprat   FALSE   11         9        4.2   -1.4    9.9      76.1
## 28       HF Alopgeni   FALSE   12         8        3.8   -3.1   10.6      79.8
## 29       HF Juncarti   FALSE   13         8        3.8   -2.8   10.3      83.6
## 30       HF Agrostol   FALSE   14         7        3.3   -2.6    9.1      86.9
## 31       HF Achimill   FALSE   15         6        2.8   -0.3    5.9      89.7
## 32       HF Juncbufo   FALSE   16         6        2.8   -2.5    8.1      92.5
## 33       HF Eleopalu   FALSE   17         4        1.9   -3.4    7.2      94.4
## 34       HF Sagiproc   FALSE   18         4        1.9   -1.4    5.2      96.2
## 35       HF Bromhord   FALSE   19         4        1.9   -1.4    5.1      98.1
## 36       HF Bellpere   FALSE   20         2        0.9   -1.7    3.5      99.1
## 37       HF Ranuflam   FALSE   21         2        0.9   -1.7    3.6     100.0
## 38       NM Scorautu    TRUE    1        19       12.6    6.0   19.2      12.6
## 39       NM Bracruta    TRUE    2        17       11.3    2.6   19.9      23.8
## 40       NM Agrostol   FALSE    3        13        8.6   -1.2   18.4      32.5
## 41       NM Eleopalu   FALSE    4        13        8.6   -1.4   18.6      41.1
## 42       NM Salirepe   FALSE    5        11        7.3   -0.2   14.8      48.3
## 43       NM Trifrepe   FALSE    6        11        7.3   -2.0   16.6      55.6
## 44       NM Anthodor   FALSE    7         8        5.3   -3.8   14.4      60.9
## 45       NM Ranuflam   FALSE    8         8        5.3   -1.2   11.8      66.2
## 46       NM Hyporadi   FALSE    9         7        4.6   -3.8   13.1      70.9
## 47       NM Juncarti   FALSE   10         7        4.6   -2.7   12.0      75.5
## 48       NM Callcusp   FALSE   11         7        4.6   -2.8   12.1      80.1
## 49       NM Airaprae   FALSE   12         5        3.3   -2.4    9.0      83.4
## 50       NM Planlanc   FALSE   13         5        3.3   -2.6    9.2      86.8
## 51       NM  Poaprat   FALSE   14         4        2.6   -2.5    7.8      89.4
## 52       NM Comapalu   FALSE   15         4        2.6   -1.8    7.1      92.1
## 53       NM Sagiproc   FALSE   16         3        2.0   -2.9    6.9      94.0
## 54       NM Achimill   FALSE   17         2        1.3   -2.4    5.0      95.4
## 55       NM Bellpere   FALSE   18         2        1.3   -2.0    4.7      96.7
## 56       NM Empenigr   FALSE   19         2        1.3   -1.9    4.6      98.0
## 57       NM Lolipere   FALSE   20         2        1.3   -2.0    4.7      99.3
## 58       NM Vicilath   FALSE   21         1        0.7   -1.0    2.3     100.0
## 59       SF Agrostol    TRUE    1        28       13.7    7.8   19.7      13.7
## 60       SF  Poatriv    TRUE    2        28       13.7    6.3   21.1      27.5
## 61       SF Alopgeni   FALSE    3        26       12.7    4.5   21.0      40.2
## 62       SF Lolipere   FALSE    4        18        8.8   -2.1   19.8      49.0
## 63       SF  Poaprat   FALSE    5        15        7.4    0.5   14.2      56.4
## 64       SF Elymrepe   FALSE    6        12        5.9   -1.0   12.8      62.3
## 65       SF Bracruta   FALSE    7        12        5.9    0.8   10.9      68.1
## 66       SF Sagiproc   FALSE    8        11        5.4   -0.8   11.5      73.5
## 67       SF Eleopalu   FALSE    9         8        3.9   -6.3   14.1      77.5
## 68       SF Scorautu   FALSE   10         8        3.9    1.4    6.4      81.4
## 69       SF Trifrepe   FALSE   11         8        3.9    0.5    7.3      85.3
## 70       SF Juncbufo   FALSE   12         7        3.4   -2.3    9.2      88.7
## 71       SF Bellpere   FALSE   13         4        2.0   -0.9    4.8      90.7
## 72       SF Ranuflam   FALSE   14         4        2.0   -1.3    5.2      92.6
## 73       SF Juncarti   FALSE   15         3        1.5   -2.4    5.3      94.1
## 74       SF Callcusp   FALSE   16         3        1.5   -2.4    5.3      95.6
## 75       SF Bromhord   FALSE   17         3        1.5   -2.1    5.0      97.1
## 76       SF Rumeacet   FALSE   18         2        1.0   -1.5    3.5      98.0
## 77       SF Cirsarve   FALSE   19         2        1.0   -1.4    3.3      99.0
## 78       SF Achimill   FALSE   20         1        0.5   -0.9    1.9      99.5
## 79       SF Chenalbu   FALSE   21         1        0.5   -0.8    1.8     100.0
##    logabun rankfreq
## 1      1.3      6.2
## 2      1.1     12.5
## 3      1.1     18.8
## 4      1.1     25.0
## 5      1.0     31.2
## 6      0.9     37.5
## 7      0.8     43.8
## 8      0.8     50.0
## 9      0.8     56.2
## 10     0.7     62.5
## 11     0.6     68.8
## 12     0.6     75.0
## 13     0.5     81.2
## 14     0.3     87.5
## 15     0.3     93.8
## 16     0.3    100.0
## 17     1.4      4.8
## 18     1.3      9.5
## 19     1.2     14.3
## 20     1.2     19.0
## 21     1.2     23.8
## 22     1.1     28.6
## 23     1.1     33.3
## 24     1.1     38.1
## 25     1.0     42.9
## 26     1.0     47.6
## 27     1.0     52.4
## 28     0.9     57.1
## 29     0.9     61.9
## 30     0.8     66.7
## 31     0.8     71.4
## 32     0.8     76.2
## 33     0.6     81.0
## 34     0.6     85.7
## 35     0.6     90.5
## 36     0.3     95.2
## 37     0.3    100.0
## 38     1.3      4.8
## 39     1.2      9.5
## 40     1.1     14.3
## 41     1.1     19.0
## 42     1.0     23.8
## 43     1.0     28.6
## 44     0.9     33.3
## 45     0.9     38.1
## 46     0.8     42.9
## 47     0.8     47.6
## 48     0.8     52.4
## 49     0.7     57.1
## 50     0.7     61.9
## 51     0.6     66.7
## 52     0.6     71.4
## 53     0.5     76.2
## 54     0.3     81.0
## 55     0.3     85.7
## 56     0.3     90.5
## 57     0.3     95.2
## 58     0.0    100.0
## 59     1.4      4.8
## 60     1.4      9.5
## 61     1.4     14.3
## 62     1.3     19.0
## 63     1.2     23.8
## 64     1.1     28.6
## 65     1.1     33.3
## 66     1.0     38.1
## 67     0.9     42.9
## 68     0.9     47.6
## 69     0.9     52.4
## 70     0.8     57.1
## 71     0.6     61.9
## 72     0.6     66.7
## 73     0.5     71.4
## 74     0.5     76.2
## 75     0.5     81.0
## 76     0.3     85.7
## 77     0.3     90.5
## 78     0.0     95.2
## 79     0.0    100.0
library(ggplot2)
library(ggrepel)

plotgg1 <- ggplot(data=bio, aes(x = rank, y = abundance)) + 
    scale_x_continuous(expand=c(0, 1), sec.axis = dup_axis(labels=NULL, name=NULL)) +
    scale_y_continuous(expand=c(0, 1), sec.axis = dup_axis(labels=NULL, name=NULL)) +
    geom_line(aes(colour=Grouping), size=1) +
    geom_point(aes(colour=Grouping, shape=Grouping), size=5, alpha=0.7) +
    geom_text_repel(data=subset(bio, labelit == TRUE), 
        aes(colour=Grouping, label=species), 
        angle=45, nudge_x=1, nudge_y=1, show.legend=FALSE) +
    scale_color_brewer(palette = "Set1") +
    labs(x = "rank", y = "abundance", colour = "Management", shape = "Management")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
plotgg1
## Warning: ggrepel: Repulsion works correctly only for rotation angles multiple of
## 90 degrees

RA.data <- rankabuncomp(dune, y=dune.env, factor='Management', 
    return.data=TRUE, specnames=c(1:10), legend=FALSE)

plotgg2 <- ggplot(data=RA.data, aes(x = rank, y = abundance)) + 
    scale_x_continuous(expand=c(0, 1), sec.axis = dup_axis(labels=NULL, name=NULL)) +
    scale_y_continuous(expand=c(0, 1), sec.axis = dup_axis(labels=NULL, name=NULL)) +
    geom_line(aes(colour=Grouping), size=1) +
    geom_point(aes(colour=Grouping), size=5, alpha=0.7) +
    geom_text_repel(data=subset(RA.data, labelit == TRUE), 
        aes(label=species), 
        angle=45, nudge_x=1, nudge_y=1, show.legend=FALSE) +
    scale_color_brewer(palette = "Set1") +
    facet_wrap(~ Grouping) +
    labs(x = "rank", y = "abundance", colour = "Management")
plotgg2
## Warning: ggrepel: Repulsion works correctly only for rotation angles multiple of 90 degrees
## ggrepel: Repulsion works correctly only for rotation angles multiple of 90 degrees
## ggrepel: Repulsion works correctly only for rotation angles multiple of 90 degrees
## ggrepel: Repulsion works correctly only for rotation angles multiple of 90 degrees