Error in [.default(DF, chr) : invalid subscript type 'list'

96 views
Skip to first unread message

Cheryl Lohr

unread,
Aug 13, 2020, 9:38:04 PM8/13/20
to secr

 

Hi folks

I'm trying to rerun some models through the package openCR. I know my code works just fine. At least it did last week, and I haven't changed it. But I'm suddenly getting this error with read.capthist

Error in [.default(DF, chr) : invalid subscript type 'list'

 

Previously, making sure I have the latest versions of R and Rstudio have fixed these kinds of issues. I currently have R4.0.2 and RStudio 1.3.1073. And I'm still getting the error. All packages have been updated.

Can anyone help me please?

 

Thanks,

Cheryl

 

 

Cheryl Lohr

Research Scientist, Animal Science Program

DBCA Biodiversity and Conservation Science

Location: 37 Wildlife Pl, Woodvale, WA 6026

Mail: Woodvale Wildlife Research Centre

Locked Bag 104 Bentley Delivery Centre

WA 6983

Ph: 94055150 (internal ext 5750)

Mob: 0407335004

 

 


This message is confidential and is intended for the recipient named above. If you are not the intended recipient, you must not disclose, use or copy the message or any part of it. If you received this message in error, please notify the sender immediately by replying to this message, then delete it from your system.

Joanne Potts

unread,
Aug 13, 2020, 9:41:38 PM8/13/20
to Cheryl Lohr, secr
Hi Cheryl,


I have been meaning to follow this up.

For us, it was fixed by ensuring ‘verify=TRUE’ when making capture histories with multi session data. Maybe that will help you? Unsure if that will resolve the issue with Dev though.

Jo

On 14 Aug 2020, at 11:37 am, Cheryl Lohr <chery...@dbca.wa.gov.au> wrote:

 

Hi folks

I'm trying to rerun some models through the package openCR. I know my code works just fine. At least it did last week, and I haven't changed it. But I'm suddenly getting this error with read.capthist

Error in [.default(DF, chr) : invalid subscript type 'list'
 

Previously, making sure I have the latest versions of R and Rstudio have fixed these kinds of issues. I currently have R4.0.2 and RStudio 1.3.1073. And I'm still getting the error. All packages have been updated.

Can anyone help me please?

 

Thanks,

Cheryl

 
 
Cheryl Lohr
Research Scientist, Animal Science Program
DBCA Biodiversity and Conservation Science
Location: 37 Wildlife Pl, Woodvale, WA 6026
Mail: Woodvale Wildlife Research Centre
Locked Bag 104 Bentley Delivery Centre
WA 6983
Ph: 94055150 (internal ext 5750)
Mob: 0407335004
 
<image001.png>
 

This message is confidential and is intended for the recipient named above. If you are not the intended recipient, you must not disclose, use or copy the message or any part of it. If you received this message in error, please notify the sender immediately by replying to this message, then delete it from your system.

-- 
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/secrgroup/MEAPR01MB4184C2ECFBEB393C4B578D5392400%40MEAPR01MB4184.ausprd01.prod.outlook.com.

Cheryl Lohr

unread,
Aug 13, 2020, 10:05:16 PM8/13/20
to Joanne Potts, secr

Hi Jo,

Thanks for getting back to me. Unfortunately, that solution didn’t work. I presume I added in the verify=TRUE correctly (see below).

 

I don’t think my case supports the idea that the problem is with R4.0 as I didn’t download R4.0 until after this error appeared. I’ve also posted this problem to StackOverflow.

 

BL<-read.capthist(captfile="2010_2011_BL_SECR_capturedata.txt",

                  trapfile = list("2010MAR_BL_SECR_traplocs.txt",

                                  "2010APR_BL_SECR_traplocs.txt",

                                  "2010JUN_BL_SECR_traplocs.txt",

                                  "2010JUL_BL_SECR_traplocs.txt",

                                  "2010AUG_BL_SECR_traplocs.txt",

                                  "2010OCT_BL_SECR_traplocs.txt",

                                  "2010NOV_BL_SECR_traplocs.txt",

                                  "2011MAR_BL_SECR_traplocs.txt",

                                  "2011MAY_BL_SECR_traplocs.txt",

                                  "2011JUN_BL_SECR_traplocs.txt",

                                  "2011AUG_BL_SECR_traplocs.txt"),

                  detector = "multi",

                  fmt=c("trapID","XY"),

                  verify=TRUE)

 

Thanks,

Cheryl

 

Cheryl Lohr

Research Scientist, Animal Science Program

DBCA Biodiversity and Conservation Science

Location: 37 Wildlife Pl, Woodvale, WA 6026

Mail: Woodvale Wildlife Research Centre

Locked Bag 104 Bentley Delivery Centre

WA 6983

Ph: 94055150 (internal ext 5750)

Mob: 0407335004

 

 

From: Joanne Potts <joa...@theanalyticaledge.com>
Sent: Friday, 14 August 2020 9:41 AM
To: Cheryl Lohr <chery...@dbca.wa.gov.au>
Cc: secr <secr...@googlegroups.com>
Subject: Re: Error in [.default(DF, chr) : invalid subscript type 'list'

 

[External Email] This email was sent from outside the department – be cautious, particularly with links and attachments.

Murray Efford

unread,
Aug 14, 2020, 1:13:37 AM8/14/20
to secr
Hi Cheryl

I assume you're using secr 4.3.0. I don't have a problem with this simple example, so I wonder if there's something odd in your data? I can't see that verify has anything to do with it, but I may be wrong.
If you want to shovel the data over to me offline I'll check it out.

Murray

[On the side - as a user you only need to provide fmt = 'trapID'.  fmt = c('trapID', 'XY') as it appears in the function definition is the odd way R remembers that there are just these two possibilities for this argument.]

> library(secr)
This is secr 4.3.0. For overview type ?secr
Warning message:
package secr was built under R version 4.0.2
>
> # generate some text files
> write.capthist(ovenCH)
>
> CH <- read.capthist(captfile = 'ovenCHcapt.txt', trapfile = 'ovenCHtrap.txt',
+     detector = 'multi')
No errors found :-)
>
> CHtrapsbysession <- read.capthist(captfile = 'ovenCHcapt.txt',
+     trapfile = list(
+         'ovenCHtrap.txt',
+         'ovenCHtrap.txt',
+         'ovenCHtrap.txt',
+         'ovenCHtrap.txt',
+         'ovenCHtrap.txt'),
+     fmt = "trapID",
+     detector = 'multi')
No errors found :-)
>
> identical(summary(CH, terse = TRUE), summary(CHtrapsbysession, terse = TRUE))
[1] TRUE
>
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

Random number generation:
 RNG
:     Mersenne-Twister
 
Normal:  Inversion
 
Sample:  Rounding
 
locale
:
[1] LC_COLLATE=English_New Zealand.1252  LC_CTYPE=English_New Zealand.1252    LC_MONETARY=English_New Zealand.1252
[4] LC_NUMERIC=C                         LC_TIME=English_New Zealand.1252    

attached
base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages
:
[1] secr_4.3.0

loaded via a
namespace (and not attached):
 
[1] Rcpp_1.0.4.6        codetools_0.2-16    lattice_0.20-41     digest_0.6.25       MASS_7.3-51.6      
 
[6] grid_4.0.0          nlme_3.1-147        magrittr_1.5        evaluate_0.14       RcppParallel_5.0.1
[11] stringi_1.4.6       rlang_0.4.6         raster_3.1-5        sp_1.4-1            Matrix_1.2-18      
[16] rmarkdown_2.1       splines_4.0.0       tools_4.0.0         stringr_1.4.0       RcppNumerical_0.4-0
[21] xfun_0.15           yaml_2.2.1          abind_1.4-5         parallel_4.0.0      compiler_4.0.0    
[26] mgcv_1.8-31         htmltools_0.4.0     knitr_1.29


Matt Rees

unread,
Aug 14, 2020, 1:26:36 AM8/14/20
to secr
Yeah I'm also having this issue on secr 4.3.0, but not on 4.2.2. 

I'm combining multiple capthists into one with multiple sessions, and that works fine. 
However, the error message (same as Cheryl) pops up when I call secr.fit. 

Let me know if you want me to send more info. 
Matt. 

Murray Efford

unread,
Aug 14, 2020, 1:46:52 AM8/14/20
to secr
I've looked at Cheryl's data and it's fine. The problem is in verify(). I think Jo meant to suggest verify = FALSE, which dodges the issue.

I introduced a bug when I adapted secr for R 4.0 (my function for coercing character variables to factors didn't allow for covariate dataframes with no columns). I think that explains the error

Until I get out the next release (possibly months away) I suggest dodging the routine verify step with verify = FALSE in read.capthist and secr.fit. I assume this also takes care of the issue in openCR. Let me know if this is not enough! My apologies.

Murray

Matt Rees

unread,
Aug 14, 2020, 2:11:37 AM8/14/20
to secr
Ah brilliant - verify = FALSE does the trick for me. 
Thanks Murray & Jo. 

Cheryl Lohr

unread,
Aug 16, 2020, 9:12:49 PM8/16/20
to Murray Efford, secr

Hi Murray,

Thanks so much for your email. The verify=FALSE has worked.

Thanks,

Cheryl

 

Cheryl Lohr

Research Scientist, Animal Science Program

DBCA Biodiversity and Conservation Science

Location: 37 Wildlife Pl, Woodvale, WA 6026

Mail: Woodvale Wildlife Research Centre

Locked Bag 104 Bentley Delivery Centre

WA 6983

Ph: 94055150 (internal ext 5750)

Mob: 0407335004

 

 

From: secr...@googlegroups.com <secr...@googlegroups.com> On Behalf Of Murray Efford
Sent: Friday, 14 August 2020 1:47 PM
To: secr <secr...@googlegroups.com>
Subject: Re: Error in [.default(DF, chr) : invalid subscript type 'list'

 

[External Email] This email was sent from outside the department – be cautious, particularly with links and attachments.

I've looked at Cheryl's data and it's fine. The problem is in verify(). I think Jo meant to suggest verify = FALSE, which dodges the issue.

--

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

Reply all
Reply to author
Forward
0 new messages