Author: Xinxin Huang
Date: 2018-04-05

# Vignette for RWildbook-demo-1

#### Xinxin Huang

#### 2018-04-05

This demo shows you how to search and pull data from Wildbook framework with RWildbook package. In this demo, all datasets below are searching for the same set of data which is all the encounter of individual “A-001” in “whaleshark.org”.

The searchWB function provides the main interface to the Wilbook framework and can be used in one of three ways.

- Case 1. You can supply filters based on the variables within the database.

    data1 <- searchWB(username="username",
                      password="password",
                      baseURL ="whaleshark.org",
                      object="Encounter",
                      individualID=c("A-001"))

- Case 2. If you have the JDOQL query for the search, You can ignore the filter arguments.

    data2<- searchWB(username="username",
                     password="password",
                     baseURL ="whaleshark.org",
                     jdoql="SELECT FROM org.ecocean.Encounter WHERE individualID == 'A-001'")

- Case 3. If you have a searchURL on hand, you can directly open the URL with function “searchWB”.

If you are using Windows then you can enter the username and password directly in the search URL like this:

    data3 <- searchWB(searchURL = "https://username:password@whaleshark.org/rest/jdoql?SELECT FROM org.ecocean.Encounter WHERE individualID == 'A-001'")

Otherwise, on MacOS or Linux you will need to supply your username and password as separate arguements:

    data3 <-
      searchWB(username = "username",
               password = "password",
               searchURL = "https://www.whaleshark.org/rest/jdoql?SELECT FROM org.ecocean.Encounter WHERE individualID == 'A-001'")

- Results.

All of these return a data frame like the following (note that the data has been altered for anonymity):

    data("vignette_1_data",package="RWildbook")
    head(vignette_1_data)[,c("location","year","month","day")]

    ##                                  location year month day
    ## 1                    Ningaloo Marine Park 2001     5  11
    ## 2                    Ningaloo Marine Park 2003     4   2
    ## 3              north ningaloo marine park 2011     5  27
    ## 4 Exmouth Dive Centre tour, Ningaloo Reef 2001     5  16
    ## 5         Ningaloo Marine Park (Northern) 2009     6  18
    ## 6            Coral Bay, Western Australia 2005     5  10