1.ertgh
2.sdfghjk
3.sdfghjk
hjklkjhgfd
# installing required packages
#install.packages("ggplot2")
devtools::install_github("dkahle/ggmap", force=TRUE)
## WARNING: Rtools is required to build R packages, but is not currently installed.
##
## Please download and install Rtools 4.0 from https://cran.r-project.org/bin/windows/Rtools/.
## Downloading GitHub repo dkahle/ggmap@HEAD
## stringi (1.7.6 -> 1.7.8) [CRAN]
## plyr (1.8.7 -> 1.8.8) [CRAN]
## Installing 2 packages: stringi, plyr
## Installing packages into 'C:/Users/mgonza79/Documents/R/win-library/4.1'
## (as 'lib' is unspecified)
##
## There are binary versions available but the source versions are later:
## binary source needs_compilation
## stringi 1.7.6 1.7.8 TRUE
## plyr 1.8.7 1.8.8 TRUE
##
## Binaries will be installed
## package 'stringi' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'stringi'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying C:
## \Users\mgonza79\Documents\R\win-library\4.1\00LOCK\stringi\libs\icudt69l.dat to
## C:\Users\mgonza79\Documents\R\win-library\4.1\stringi\libs\icudt69l.dat: Invalid
## argument
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying C:
## \Users\mgonza79\Documents\R\win-library\4.1\00LOCK\stringi\libs\x64\stringi.dll
## to C:\Users\mgonza79\Documents\R\win-library\4.1\stringi\libs\x64\stringi.dll:
## Permission denied
## Warning: restored 'stringi'
## package 'plyr' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'plyr'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying C:
## \Users\mgonza79\Documents\R\win-library\4.1\00LOCK\plyr\libs\x64\plyr.dll to C:
## \Users\mgonza79\Documents\R\win-library\4.1\plyr\libs\x64\plyr.dll: Permission
## denied
## Warning: restored 'plyr'
##
## The downloaded binary packages are in
## C:\Users\mgonza79\AppData\Local\Temp\RtmpiS6UrJ\downloaded_packages
## WARNING: Rtools is required to build R packages, but is not currently installed.
##
## Please download and install Rtools 4.0 from https://cran.r-project.org/bin/windows/Rtools/.
## * checking for file 'C:\Users\mgonza79\AppData\Local\Temp\RtmpiS6UrJ\remotes35181ed9630a\dkahle-ggmap-c5d234c/DESCRIPTION' ... OK
## * preparing 'ggmap':
## * checking DESCRIPTION meta-information ... OK
## * checking for LF line-endings in source and make files and shell scripts
## * checking for empty or unneeded directories
## Removed empty directory 'ggmap/.github'
## * building 'ggmap_3.0.1.900.tar.gz'
##
## Installing package into 'C:/Users/mgonza79/Documents/R/win-library/4.1'
## (as 'lib' is unspecified)
#get working directory
getwd()
## [1] "C:/Users/mgonza79/Downloads"
#set working directory
setwd("C:/Users/mgonza79/Downloads")
#loading library
library(ggplot2, warn.conflicts = FALSE)
## Warning: package 'ggplot2' was built under R version 4.1.3
library(ggmap)
## i Google's Terms of Service: <https://mapsplatform.google.com>
## i Please cite ggmap if you use it! Use `citation("ggmap")` for details.
#Downloading and exploring the data
mydata<-readRDS("dataSWTH.rds")
head(mydata)
## ts sig port motusTagID mfgID recvDeployLat
## 1 2018-08-03 10:19:27 -39.2407 3 30421 355 45.4307
## 2 2018-08-03 10:19:42 -42.7479 4 30421 355 45.4307
## 3 2018-08-03 10:19:49 -51.2009 5 30421 355 45.4307
## 4 2018-08-03 10:20:10 -44.5063 3 30421 355 45.4307
## 5 2018-08-03 10:20:31 -55.2335 4 30421 355 45.4307
## 6 2018-08-03 10:21:07 -50.4889 4 30421 355 45.4307
## recvDeployLon recvDeployName recvSiteName antBearing
## 1 -73.9385 McGill_Bird_Observatory McGill_Bird_Observatory 120
## 2 -73.9385 McGill_Bird_Observatory McGill_Bird_Observatory 300
## 3 -73.9385 McGill_Bird_Observatory McGill_Bird_Observatory 220
## 4 -73.9385 McGill_Bird_Observatory McGill_Bird_Observatory 120
## 5 -73.9385 McGill_Bird_Observatory McGill_Bird_Observatory 300
## 6 -73.9385 McGill_Bird_Observatory McGill_Bird_Observatory 300
## speciesEN speciesFR speciesSci recvProjName
## 1 Swainson's Thrush Grive à dos olive Catharus ustulatus MONTREAL_MOULT
## 2 Swainson's Thrush Grive à dos olive Catharus ustulatus MONTREAL_MOULT
## 3 Swainson's Thrush Grive à dos olive Catharus ustulatus MONTREAL_MOULT
## 4 Swainson's Thrush Grive à dos olive Catharus ustulatus MONTREAL_MOULT
## 5 Swainson's Thrush Grive à dos olive Catharus ustulatus MONTREAL_MOULT
## 6 Swainson's Thrush Grive à dos olive Catharus ustulatus MONTREAL_MOULT
#determine the number of individuals
unique(mydata$motusTagID)
## [1] 30421 31092 31093 31284 31285 31291 31297 31083 31088 31253
## Levels: 30421 31083 31088 31092 31093 31253 31284 31285 31291 31297
length(unique(mydata$motusTagID))
## [1] 10
ggplot(data = mydata, aes(x = as.POSIXct(round(ts, "hour")),y=as.factor(motusTagID), colour = recvSiteName))+theme_bw() + geom_point() +labs(x = "Time (rounded to hour)", y = "MotusTagID") +scale_colour_discrete(name = "Receiver")
#create subset data
subset31284 <- subset(mydata, motusTagID == 31284)
#create solo-bird plot
subset31284 <- subset(mydata, motusTagID == 31284)
ggplot(data = subset31284, aes(x = as.POSIXct(round(ts, "hour")),y=as.factor(motusTagID), colour = recvSiteName))+theme_bw() + geom_point() +labs(x = "Time (rounded to hour)", y = "MotusTagID") +scale_colour_discrete(name = "Receiver")
ggplot(subset31284,aes(ts, sig, colour = as.factor(antBearing))) +geom_point() + facet_grid(recvSiteName ~ .) + theme_bw()
#Create a basemap using ggmap
gmap <- get_stamenmap(bbox = c(left = -95, right = -57,bottom = 0, top = 48), maptype ="terrain-background", zoom =6)
## i Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
## i 77 tiles needed, this may take a while (try a smaller zoom?)
#view base map using the plot() function
plot(gmap)
#Add points to the map and display
#create coordinate map:
ggmap(gmap) + theme_bw() + geom_point(data = mydata, aes(x = recvDeployLon, y = recvDeployLat), shape = 21, colour = "black", fill = "yellow") +geom_path(data = mydata, aes(x = recvDeployLon, y = recvDeployLat, group = motusTagID, col = as.factor(motusTagID))) +scale_color_discrete(name = "MotusTagID")
#use bird 31088
tag31088 <- subset(mydata, motusTagID == 31088)
#visualize the detentions of this bird 31088
ggplot(tag31088,aes(ts, sig, colour = as.factor(antBearing))) +geom_point() + facet_grid(recvSiteName ~ .) +theme_bw()
#Subset to a period of 2 days. September 09-September 11
sub_31088 <- subset(tag31088, ts > "2018-09-09 00:00:00" & ts < "2018-09-11 06:00:00" )
#plot this
ggplot(sub_31088,aes(ts, sig, colour = as.factor(antBearing)))+geom_point() +facet_grid(recvSiteName ~ .) + theme_bw()
the pattern seem to correspond to diurnal fluctuation
sdfghjkl
positiondfghj
sadfghjoihgfds