WildCoLab / Introduction-to-Camera-Trap-Data-Management-and-Analysis-in-R

An introduction to analysing standardised camera trap data from the WildCAM network.
Creative Commons Zero v1.0 Universal
20 stars 3 forks source link

Objects being masked by other packages #3

Open KGargus opened 3 years ago

KGargus commented 3 years ago

Hi, I used the Wildco tutorial data to produce the horizontal bar graph for Raw Camera Detections (ie. the total detections and proportion of sites detected) and it worked. Now with my own data I am not getting a graph and I think it has to do with a problem loading the required packages...Objects are being masked by other packages (I did not have this problem the first time I used the code). If you have any recommendations, that would be appreciated!

independent detections totaldetections_bargraph

library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

Warning message: package ‘dplyr’ was built under R version 4.0.5

leaflet should be installed after first time/use, but might need to load it

to install: install.packages("leaflet")

to run library("leaflet")

library("leaflet") Warning message: package ‘leaflet’ was built under R version 4.0.5 library(dplyr) library(colortools) library(kriging) Warning message: package ‘kriging’ was built under R version 4.0.5 library(corrplot) corrplot 0.88 loaded Warning message: package ‘corrplot’ was built under R version 4.0.5 library(lubridate)

Attaching package: ‘lubridate’

The following objects are masked from ‘package:base’:

date, intersect, setdiff, union

Warning message: package ‘lubridate’ was built under R version 4.0.5

library(kableExtra)

Attaching package: ‘kableExtra’

The following object is masked from ‘package:dplyr’:

group_rows

Warning message: package ‘kableExtra’ was built under R version 4.0.5

ChrisBeirne commented 3 years ago

Ohhh interesting - if you would be happy to share the input data you are using I could have a look at it to figure out exactly where it is breaking?

The best workaround for masking issues is to include the package you want in the function call for example dplyr::summarize(), if you can figure out where the issue is?

KGargus commented 3 years ago

Thanks Chris,

I am attaching the input data...I don't have a lot of background using R - I am not sure which package is being used specifically to make that graph (since I load all the packages before I start running the code). This is the section of code I was trying to run:

Raw camera detections

To date, there have been r nrow(dat) image classifications. Of these, r nrow(dat[dat$Blank==FALSE,]) are classified as blanks (r round((nrow(dat[dat$Blank==TRUE,])/nrow(dat))*100,1)% of the total dataset).

Of the detections which have been identified, there are r length(levels(factor(dat$Species))) different catageories.


layout(matrix(c(1,1,2), 1, 3, byrow = TRUE))
det.sum.total <- as.data.frame(count(dat[dat$Blank==FALSE & is.na(dat$Species)==FALSE,], Species))
det.sum.total <- det.sum.total[order(det.sum.total$n),]
par(mar=c(5,16,1,1))
barplot(det.sum.total$n, names.arg = paste0(det.sum.total$Species,
                                            " (n =", det.sum.total$n,")")   , las=1, cex.names=1, xlab="Total detections", horiz=T)
i <-1
for(i in 1:nrow(det.sum.total))
{
  tmp <- subset(dat, Species==det.sum.total$Species[i])
  det.sum.total$Locations[i] <- length(unique(tmp$Deployment.Location.ID))
}
par(mar=c(5,1,1,1))
barplot(det.sum.total$Locations/n.stat, las=1, cex.names=0.7, xlab="Proportion of sites detected", horiz=T, xlim=c(0,1))
abline(v=1, lty=2)
________________________________
From: Chris Beirne ***@***.***>
Sent: Tuesday, June 29, 2021 4:55 PM
To: WildCoLab/WildCo_Data_Analysis ***@***.***>
Cc: Kaitlin Gargus ***@***.***>; Author ***@***.***>
Subject: Re: [WildCoLab/WildCo_Data_Analysis] Objects being masked by other packages (#3)

Ohhh interesting - if you would be happy to share the input data you are using I could have a look at it to figure out exactly where it is breaking?

The best workaround for masking issues is to include the package you want in the function call for example dplyr::summarize(), if you can figure out where the issue is?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://github.com/WildCoLab/WildCo_Data_Analysis/issues/3#issuecomment-870971265>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AUFCAD6ESP6WY6NONGNWYWLTVJFP5ANCNFSM47QWMEAA>.
ChrisBeirne commented 3 years ago

No problem - it is really useful for us to test this code on new projects. No attachments came through - try sending them to c.w.beirne@ubc.ca