joenomiddlename / Censored_Longline_RCode

A repository storing all the R code used to run the simulation experiments and case study seen in the paper: *A statistical censoring approach accounts for hook competition in abundance indices from longline surveys*
GNU General Public License v3.0
2 stars 1 forks source link

Can't run case study vignette #1

Open andrew-edwards opened 1 year ago

andrew-edwards commented 1 year ago

Specifically, checking I can run Case_Study_Analysis_Standalone_After_Revisions.Rmd vignette (to check if I can tweak axis labels regarding > \phatpistar). But it can't read in the data:

> data <- readRDS("Case_Study_Data.rds")
> data
$Reduced_data_sp
Error in `vec_size()`:
! `x` must be a vector, not a <sfc_POINT/sfc> object.
Run `rlang::last_error()` to see where the error occurred.

Checking the error:

> rlang::last_error()
<error/vctrs_error_scalar_type>
Error in `vec_size()`:
! `x` must be a vector, not a <sfc_POINT/sfc> object.
---
Backtrace:
  1. base `<fn>`(x)
 22. vctrs:::stop_scalar_type(`<fn>`(`<sf_POINT>`), "x", `<fn>`(vec_size()))
 23. vctrs:::stop_vctrs(...)
Run `rlang::last_trace()` to see the full context.
andrew-edwards commented 1 year ago

Okay, I think data just can't get printed simply (as it's a list, though they usually can be). The actual error when running the vignette comes further down, in chunk choosing-pistar:

label: choosing-pistar (with options) 
List of 4
 $ cache  : logi FALSE
 $ warning: logi FALSE
 $ message: logi FALSE
 $ eval   : logi TRUE

Quitting from lines 898-1097 (Case_Study_Analysis_Standalone_After_Revisions.Rmd) 
Error in `vec_size()`:
! `x` must be a vector, not a <sfc_POINT/sfc> object.
Backtrace:
  1. Reduced_data_sp %>% filter(year >= 1998)
 11. vctrs:::stop_scalar_type(`<fn>`(`<sf_POINT>`), "x", `<fn>`(vec_size()))
 12. vctrs:::stop_vctrs(...)

Hard to tell exactly where (as a big chunk) without more detective work....

joenomiddlename commented 1 year ago

Seems to be an issue with your sf package version: see https://github.com/r-spatial/sf/issues/1387

andrew-edwards commented 1 year ago

From my base R:

ylab=expression( paste("Log (prop. of ", values >= italic(x), ")")),
       mgp=mgpVals)
jdunic commented 1 year ago

In case someone else needs this info, I needed to set sf::sf_use_s2(FALSE) to avoid this error.