Problems reading my edf and tdf with data2oSCR()

208 views
Skip to first unread message

H Brian Underwood

unread,
Apr 3, 2020, 10:47:21 AM4/3/20
to oSCR
I have edf and tdf from scrbook that work fine, but won't read into oSCR helper function. Getting some traps in edf not showing up in tdf. They are there, so something else not working. I have fewer encounters than traps, so wondering if that is throwing the error? I tried converting session.id to factors, still no joy.  Any advice would be appreciated.

Brian

Jeffrey Royle

unread,
Apr 3, 2020, 11:44:19 AM4/3/20
to oSCR
hi Brian,
 if you have a trap identity in the EDF data  but it doesn't show up in your TDF then this throws an error , so just make sure your TDF contains all possible traps...  This is a common error in data formatting often due to slight differences in the trap names between separate excel files or similar.
regards
andy


On Fri, Apr 3, 2020 at 10:47 AM 'H Brian Underwood' via oSCR <oscr_p...@googlegroups.com> wrote:
I have edf and tdf from scrbook that work fine, but won't read into oSCR helper function. Getting some traps in edf not showing up in tdf. They are there, so something else not working. I have fewer encounters than traps, so wondering if that is throwing the error? I tried converting session.id to factors, still no joy.  Any advice would be appreciated.

Brian

--
You received this message because you are subscribed to the Google Groups "oSCR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oscr_package...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/oscr_package/f5cce0b5-6814-4398-a090-23de267f4291%40googlegroups.com.

Chris Sutherland

unread,
Apr 3, 2020, 1:36:17 PM4/3/20
to oscr_p...@googlegroups.com

Hi Brian,

 

The following is not tested, but should be about what you need to identify the culprit.

 

If this is single session data, then you can use the following to

 

#change object (edf, tdf) and column names (trap) to match your data

edf$trap[!which(edf$trap %in% tdf$trap)]

 

If it’s multi-session, throw it in a loop:

 

#change object and column names to match your data

#also, there is a tdf per session, so let’s assume you wrapped them in a list:

tdf.ls <- list(tdf1, tdf2,etc, )

for(i in 1:length(unique(edf$session))){

  tmp.sesh <- unique(edf$session)[i]   

  tmp.edf <- subset(edf, session == tmp.sesh)

  tmp.edf$trap[!which(tmp.edf$trap %in% tdf.ls[[i]]$trap)]

H. Brian Underwood

unread,
Apr 3, 2020, 2:17:21 PM4/3/20
to oscr_p...@googlegroups.com
Thanks, Chris.

edf$trap %in% tdf$trap evaluates to all "TRUE"

I'm trying to find a work around by supplying scrFrame() with what it needs.

Brian



"Humor is the universal solvent against the abrasive elements of life." Senator Alan Simpson.


Chris Sutherland

unread,
Apr 3, 2020, 3:33:12 PM4/3/20
to oSCR
Hmmm. Strange. Would you mind sending along the edf and edf files so I can take a look?

H. Brian Underwood

unread,
Apr 3, 2020, 4:28:47 PM4/3/20
to oscr_p...@googlegroups.com
I will once I've exhausted a few more options.

Brian



"Humor is the universal solvent against the abrasive elements of life." Senator Alan Simpson.

H Brian Underwood

unread,
Apr 6, 2020, 10:54:40 AM4/6/20
to oSCR
data2oSCR() revealed issues with my EDFs (arghhh....). Fixed them and life is good again. I try to work these things out myself when possible.  Thanks for your input.

Brian

To unsubscribe from this group and stop receiving emails from it, send an email to oscr_p...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "oSCR" group.

To unsubscribe from this group and stop receiving emails from it, send an email to oscr_p...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "oSCR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oscr_p...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "oSCR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oscr_p...@googlegroups.com.

Molly Parren

unread,
Jul 9, 2020, 11:17:55 AM7/9/20
to oSCR
Hi Brian! 

I am having the exact same issue you described in this thread and was wondering what issues you found with your EDF? I'm hoping I have a similar issue hidden away. 

When using edf$TRAP %in% tdf$TRAP I am also getting all "TRUE". 

Thanks so much!

Molly 
Message has been deleted

chris...@gmail.com

unread,
Apr 1, 2023, 2:41:50 PM4/1/23
to oscr_p...@googlegroups.com

Hello Filipe,

 

When I run your code I am not abel to reproduce your error, and actually the following code works just fine:

 

library(oSCR)

sf <- data2oscr(edf = edf,

                sess.col = 1,

                id.col = 2,

                occ.col = 3,

                trap.col = 4,

                tdf = list(tdf),

                K = 104,

                ntraps = nrow(tdf))$scrFrame

sf

 

#                S1

# n individuals  15

# n traps       100

# n occasions   104

#

#                    S1

# avg caps         1.53

# avg spatial caps 1.33

# mmdm             0.03

 

Does your data2oscr() code look just like what I have above?

 

Chris

 

From: oscr_p...@googlegroups.com <oscr_p...@googlegroups.com> On Behalf Of Filipe Rocha
Sent: Friday, March 31, 2023 5:01 PM
To: oSCR <oscr_p...@googlegroups.com>
Subject: Re: [oscr] Problems reading my edf and tdf with data2oSCR()

 

Dear all,

I have the exact same issue of this topic when trey to read the edf and tdf with data2oscr. Would you mind sharing how did you fix that issue?

 

 The message I'm getting is:

 

some trap names in EDF not in TDF Warning messages: 1: In xtfrm.data.frame(x) : cannot xtfrm data frames 

2: In xtfrm.data.frame(x) : cannot xtfrm data frames 

 

However, all the trap names in edf exist in tdf:

edf$trap[!which(edf$trap %in% tdf$trap)] character(0) > edf$trap %in% tdf$trap [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

 

 I have tried to work around this issue but haven't found a solution. Could you, please assist me with this?

I attach the tdf and edf tables, in case it helps.

 

Thank you for your assistance!

 

Filipe

 

To unsubscribe from this group and stop receiving emails from it, send an email to oscr_package...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/oscr_package/f02ac3e4-44bc-4d72-b7f2-ac9140464e3cn%40googlegroups.com.

Filipe Rocha

unread,
Apr 4, 2023, 9:30:22 AM4/4/23
to oscr_p...@googlegroups.com
Dear Chris,
Thank you for your fast reply.
Yes, my code looks just like yours. And, even when I run the code you sent, I'm getting the same error:

> sf <- data2oscr(edf = edf,
+                 sess.col = 1,
+                 id.col = 2,
+                 occ.col = 3,
+                 trap.col = 4,
+                 tdf = list(tdf),
+                 K = 104,
+                 ntraps = nrow(tdf))$scrFrame
some trap names in EDF not in TDF
Warning messages:
1: In xtfrm.data.frame(x) : cannot xtfrm data frames
2: In xtfrm.data.frame(x) : cannot xtfrm data frames

Given that you weren't able to reproduce the error, I thought may be something related to the versions of R and the packages. I updated them all (currently I'm using R 4.2.3 and oSCR 0.42.0) but keep getting the same error!
Do you have any other suggestion?

Thank you,
Filipe


You received this message because you are subscribed to a topic in the Google Groups "oSCR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/oscr_package/9jMjmfg3Gf0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to oscr_package...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/oscr_package/018f01d964c9%249d5f4190%24d81dc4b0%24%40gmail.com.


--
Filipe Rocha, PhD student
CIBIO/InBIO - Research Center in Biodiversity and Genetic Resources
University of Porto
Campus Agrário de Vairão,
Rua Padre Armando Quintas
4485-661, Vairão
Portugal

chris...@gmail.com

unread,
Apr 4, 2023, 12:52:05 PM4/4/23
to oscr_p...@googlegroups.com

Hmmm, interesting.

I’m all up to date and using the same version of oSCR as you.

 

Can you send me a full script.

Filipe Rocha

unread,
Apr 4, 2023, 5:48:45 PM4/4/23
to oscr_p...@googlegroups.com
Dear Chris,
Thank you for your reply.

In attachment I send the script and the Excel files with the data. The data might be slightly different from the one I sent before because I grouped the information from the cameras installed in the same station. Anyway, the result is the same...

Thank you for your help,
Best regards,
Filipe
 

oSCR_analysis.R
Cameras_PNM_effort_table.xlsx
Cat_detections.xlsx
.RData

Daniel Linden

unread,
Apr 5, 2023, 7:20:30 AM4/5/23
to oSCR
Hi Filipe, the problem is that your objects are tibbles and they need to be data.frames.  Just add `%>% as.data.frame()` to your object creation chunks and it should work.

Filipe Rocha

unread,
Apr 6, 2023, 1:18:15 AM4/6/23
to oscr_p...@googlegroups.com
Thank you Daniel,
Your suggestion solved the problem!

Regards,
Filipe 

chris...@gmail.com

unread,
Apr 6, 2023, 7:46:51 AM4/6/23
to oscr_p...@googlegroups.com

Hi everyone,

 

Just an update here to say that this has happened enough times to motivate me to add check to data2oscr() that ensures the EDF is a data.frame (ie. converts from a tibble). Not a huge update so I guess the recommendation for now is that if you are using the existing version of oSCR (0.42.0) make sure your edf is a data.frame not a tibble, but any future installs will do this on the fly 😊

 

Thanks Dan!

Reply all
Reply to author
Forward
0 new messages