The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
library("pestr")
library("dplyr")
Assume that you are assessing pest threats to Abies alba – European silver fir. It would be wise to go to EPPO Global Database, type Abies alba in search field and check all the information you need, copy paste them into spreadsheet and make some analyses. On the other hand, you can just use pestr
package and do everything easily from R
directly saving time on whole copy-pasting procedures. To make this example easy lets assume that your goal is to check number of taxons and number of particular types (major, minor, etc.) of pests. Therefore steps you would need to make in R
are presented below.
I assume that you already have eppocodes.sqlite database in your working directory. If not you should download it manually from EPPO Data Services or using eppo_database_download
function. I also assume that you have basic knowledge of using dplyr
package and piping %>%
operator.
First you need valid eppocode of Abies alba. To do this you will need to use eppo_names_tables
function and save your results to a variable like in the code example below:
<- eppo_names_tables("Abies alba") abies_alba
This variable will be our input for next step.
We can now look for all the existing pests of Abies alba that exists in EPPO Data Services. To do this we need to use eppo_tabeltools_pests
function. There are two options how you can access the information.
eppo_names_tables
output as an argument:You will need result of eppo_names_tables
function as first argument and the second one is token – which allows you to connect to EPPO API. You get it by registering to EPPO Data Services which is free of charge. You need to paste your token to create_eppo_token
function and assign the results to a variable (here we use eppo_token
) that will be used among all pestr
functions that connect to EPPO API.
eppo_tabletools_pests
will take 3 arguments with this approach:
create_eppo_token
;TRUE
Below code shows this in action:
### Firsr create eppo_token variable
<- eppo_create_token("<place your eppo token here>")
eppo_token
### For token argument, please use eppo_token
<- eppo_tabletools_pests(token = eppo_token,
abies_alba_pests raw_eppocodes = "ABIAL",
use_raw_codes = TRUE)
Looking at structure of abies_alba_pests
variable we see that it is a list containing 2 data.frame
.
str(abies_alba_pests)
#> List of 2
#> $ long_table :'data.frame': 51 obs. of 5 variables:
#> ..$ eppocode : chr [1:51] "ABIAL" "ABIAL" "ABIAL" "ABIAL" ...
#> ..$ pests_eppocode: chr [1:51] "MELMME" "MELMMD" "ACLRGL" "ACLRVA" ...
#> ..$ idclass : int [1:51] 10 10 9 9 9 9 9 9 9 9 ...
#> ..$ labelclass : chr [1:51] "Experimental" "Experimental" "Host" "Host" ...
#> ..$ fullname : chr [1:51] "Melampsora medusae (as Abies)" "Melampsora medusae f. sp. deltoidis (as Abies)" "Acleris gloverana (as Abies)" "Acleris variana (as Abies)" ...
#> $ compact_table: tibble [1 × 2] (S3: grouped_df/tbl_df/tbl/data.frame)
#> ..$ eppocode: chr "ABIAL"
#> ..$ pests : chr "Experimental: Melampsora medusae (as Abies), Melampsora medusae f. sp. deltoidis (as Abies); Host: Acleris glov"| __truncated__
#> ..- attr(*, "groups")= tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
#> .. ..$ eppocode: chr "ABIAL"
#> .. ..$ .rows : list<int> [1:1]
#> .. .. ..$ : int 1
#> .. .. ..@ ptype: int(0)
#> .. ..- attr(*, ".drop")= logi TRUE
The long_table element contains what we actually need for our analyses: pest_eppocode and labelclass columns. Lets start with latter.
Pest types are stored in labelclass column. We will use few very basic R
and dplyr
package commands to check numbers we are interested in.
### First select colums labelclass from long_table element,
### and use table to check frequencies
$long_table %>%
abies_alba_pests::select(labelclass) %>%
dplyrtable()
#> .
#> Experimental Host Major host
#> 2 46 3
### Than we can create very simple barplot to visualize number of
### species in particular type of pest
$long_table %>%
abies_alba_pests::select(labelclass) %>%
dplyrtable() %>%
barplot(xlab = "Type of pest", ylab = "Number of species",
col = "#AF0011", ylim = c(0, 30))
Obtaining number of pests taxons is not very complicated. Since we can use eppocodes
directly, we can pass whole column to eppo_tabletools_taxo
function, which will retrieve data on pests taxonomy.
### Extract eppocodes of pests
<- abies_alba_pests$long_table %>%
pests_eppocodes ::select(pests_eppocode) %>%
dplyrunlist()
Now, we can pass pest_eppocodes
variable as raw_eppocodes
argument:
<- eppo_tabletools_taxo(token = eppo_token,
pests_taxonomy raw_eppocodes = pests_eppocodes,
use_raw_codes = TRUE)
This time we can take a shortcut and use second element of list compact_table
. We can now check the numbers using table
function and plot results with simple barplot
.
$compact_table %>%
pests_taxonomy::select(taxonomy) %>%
dplyrtable()
#> .
#> Arthropoda Chromista Fungi Nematoda Plantae
#> 34 2 10 1 4
$compact_table %>%
pests_taxonomy::select(taxonomy) %>%
dplyrtable() %>%
barplot(xlab = "Classification of pest", ylab = "Number of species",
col = "#AF0011", ylim = c(0, 30))
Now, knowing basics of how functions interacts, you are ready to play with your own workflows and analyses.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.