forked from MotusWTS/MotusRBook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-AppendixB.Rmd
140 lines (93 loc) · 8.2 KB
/
10-AppendixB.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Appendix - Troubleshooting {#appendixB}
```{r tidyr9, echo = FALSE, message = FALSE, warning = FALSE}
library(knitr)
opts_chunk$set(tidy.opts=list(width.cutoff=50), tidy = FALSE)
```
As a first step, always ensure you are using the latest version of the motus package (see Appendix \@ref(checkVersionB)), and you have all required packages installed, loaded, and up to date (see Chapter \@ref(loadingPackages)).
While attempting to download data with the motus package, you may encounter errors, many of which are likely due to an interrupted connection. **Always ensure you are connected to the internet when using the `tagme()` function with `update = TRUE`**. Most issues can be solved by either logging out of the motus package, or by restarting R and resuming the download using `tagme()`. If errors persist and you are unable to download your data, the server may be temporarily offline. Please contact Motus with any concerns at [email protected].
## General Problems
Many, *many*, problems arise from conflicts between R packages which may be out of date.
If you have a problem that you can't seem to resolve, try the following steps in order (stopping when the problem goes away):
1. Update `motus` and packages that `motus` depends on. (You may first need to install the `remotes` package). **Re-start R**
```{r eval = FALSE}
remotes::update_packages("motus")
```
2. Update all your packages. **Re-start R**
```{r eval = FALSE}
remotes::update_packages()
```
3. Update R <https://cran.r-project.org/>. (You may have to reinstall packages)
## Logging out of motus {#motusLogout}
```{r motusLogout, eval = FALSE}
motusLogout()
```
## Resume data download {#resumeDownload}
To resume your data download, run `tagme()` again, but do not include `new = TRUE`:
```{r tagmeResume, eval = FALSE}
tagme(project.num, update = TRUE, dir = ...)
```
## Google Maps {#googleMapsKey}
As of October 16, 2018 recent updates require the use of a Google key to access google maps. To obtain an access key, you must be a registered Google user with **up to date billing information**, however you do not have to pay for the service (for the first little while at least). To obtain a key:
1. login to the [Google Cloud Platform](https://cloud.google.com/console/google/maps-apis/overview).
2. If you do not already have a project then create one.
3. Check that you have current billing information - you will not be charged but it must be present and up to date.
4. Under the navigation menu on the left, click APIs & Services > Credentials, then click Create credentials > API key.
5. You may need to enable Google Maps Static API. You can do this through the navigation menu in the upper left corner, and selecting APIs & Services > library, choosing "Google Maps Static API" and clicking "Enable".
Full details are listed under "Detailed Guide" [here](https://developers.google.com/maps/documentation/javascript/get-api-key). Note that you may have to enable Google Maps Static API. For troubleshooting see [here](https://groups.google.com/forum/#!topic/motus-wts/UxqFIO6Pcmo) and [here](https://groups.google.com/forum/#!topic/motus-wts/UxqFIO6Pcmo and https://github.com/dkahle/ggmap/issues/51).
Once you have your access key, you'll need to provide it with the call `register_google()`, **each time you start a new R session you will be required to enter your key.**
Then you can create Google maps with the `ggmap` package using the `get_googlemap()` function and specifying the lat/lon center of your map (as opposed to bounding box as with stamen maps).
## Common problems and solutions:
### I cannot access Project 176 / I download 0 records from Project 176
Remember that project 176 is *only* accessible with the username and password: **`motus.sample`**.
### I get the message "Auto-disconnecting SQLiteConnection" one or multiple times after using tagme()
If this occurs after data download has finished, this message can be ignored. If it occurs during an active download, the connection will usually be maintained and the download will continue. However if the download stops, simply run `tagme()` again. If that does not work, we suggest logging out of the motus package or restarting R (see sections \@ref(motusLogout) and \@ref(resumeDownload)).
### I get an "Internal Server Error" message when using tagme(..., update = TRUE)
If you get this message while updating your .motus file, use `tagme()` again to continue the download.
### I get an "Error: Forbidden" message when using tagme()
This error may occur if you are attempting to download multiple projects simultaneously from the same user account. If you get this error, please logout of the motus package, and try `tagme()` again (see sections \@ref(motusLogout) and \@ref(resumeDownload)).
### I get an error "Object 'xxxx' not found", referring to a table or field name, or some of your examples in the book do not work.
Be sure to start the steps from the top of the chapter and run them in sequential order. Another possibility is that your .motus database hasn't been updated to support the latest version of the motus package.
To ensure that your .motus file is up-to-date with the motus package:
```{r checkVersion, eval = FALSE}
sql.motus <- tagme(project.num, dir= ...)
checkVersion(sql.motus)
```
To correct any warnings, you should follow these steps:
1. download the latest version of the motus package (refer to Chapter \@ref(loadingPackages)).
2. terminate and restart your R session.
3. load the motus library using `library(motus)` in your R console.
4. load your sqlite file. Look for notes on the console indicating that your database is being updated.
5. check the version again.
```{r checkVersionFix, eval = FALSE}
library(motus)
sql <- tagme(project.num, dir= ...)
checkVersion(sql)
```
### I get an error `Error in rsqlite_connect(dbname, loadable.extensions, flags, vfs) : Could not connect to database: unable to open database file` when attempting to run `tagme()`
If you get this message, it's likely that you're attempting a new download or update to a nonexistant directory. The directory is specified in the **`dir = ""`** command of the `tagme()` function. If the directory is not specified, files will be saved to your working directory. Use `getwd()` to determine your current working directory. Use `setwd()` to set a new working directory. To specify a location to save files from your working directory use "./" followed by the file path.
```{r setWorkingDirectory, eval = FALSE}
getwd() # show working directory, in this case it's "C:/Documents"
# downloads data to your working directory
tagme(proj.num, new = TRUE, update = TRUE)
# downloads data to the data folder within your working directory
# ie. the file path C:/Documents/data
tagme(proj.num, new = TRUE, update = TRUE, dir = "./data/")
# downloads data to the file path C:/Downloads
tagme(proj.num, new = TRUE, update = TRUE, dir = "C:/Downloads")
```
### I see GPS coordinates of "0" or "999"
These values are recorded from the GPS unit in the field. Values like these should be ignored, you can replace these with `NA`, or insert the `recvDeployLat`/`recvDeplOyLon` values which are taken from receiver deployment metadata entered by users.
```{r replaceGPSValues, eval = FALSE}
## to replace gpsLat/gpsLon values of NA, 0, or 999 with that of receiver deployment metadata in the alltags table, and read into a data.frame
df.alltags <- tbl.alltags %>%
mutate(recvLat = if_else((is.na(gpsLat)|gpsLat == 0|gpsLat == 999),
recvDeployLat, gpsLat),
recvLon = if_else((is.na(gpsLon)|gpsLon == 0|gpsLon == 999),
recvDeployLon, gpsLon)
collect() %>% as.data.frame
```
### I see port with a value of -1
Port "-1" represents the "A1+A2+A3+A4" compound antenna which is sometimes reported in Lotek .DTA file detections. This likely means the receiver has combined the signal from 4 antennas to detect the tag.
### I get the error `Error in rsqlite_fetch(res@ptr, n = n) : database disk image is malformed`
This is likely due to corrupt files which can occur during download. The easiest solution is to delete your current .motus file and download from scratch.
Of course, there is always the possibility that the book contains errors! If this does not work, please contact [email protected].