GlobalFishingWatch / forcedlabor

forcedlabor: forced labor model package
GNU General Public License v3.0
0 stars 0 forks source link

dependencies warning #2

Open rociojoo opened 2 years ago

rociojoo commented 2 years ago
  '::' or ':::' import not declared from: ‘parallely’
  Unexported object imported by a ':::' call: ‘tidyselect:::where’
    See the note in ?`:::` about the use of this operator.

Not sure about what to do here.

natemiller commented 2 years ago

@rociojoo There may be a couple issues here.

  1. it looks like on line 236 in ml_train_predict.R you reference parallely::availableCores() (missing an L) which should be parallelly::availableCores(). Because this package doesn't exist you obviously don't have it in your DESCRIPTION file, but R is complaining that you are trying to import a function from a package you have not declared in the DESCRIPTION as an import.

You also have the issue where the R CMD check is frowning upon the use of the :::, but as you have noted where is not exported by tidyselect, so it is hard to figure out how to reference it. Looking around it seems like the best option would be to add utils::globalVariables("where") close to function where you call where, but outside of the function definition.

Granted, I haven't tried this so it may still fail, but it is what I could find.

#' Preprocessing of offenders, possible offenders, non offenders and unlabeled
#' data
#'
#' @param fl_data data frame of offenders. Needs to have columns such as: a gear
#' (character),
#' ssvid (character), engine_power_kw (double), tonnage_gt (double),
#' length_m (double), ais_type (character), event_ais_year (integer),
#' fl_event_id (integer), known_offender (double), known_non_offender (integer),
#' possible_offender (double)
#' @param tidy_data data frame of AIS. Needs to have the same columns as
#' fl_data.
#' @param gears_interest vector of character elements with names of the gears
#' of interest.
#' @param vars_to_factor vector of character elements with names of columns to
#' convert from character to factor. They have to be columns existing in fl_data
#' and tidy_data.
#' @param vars_remove vector of character elements with names of columns to
#' remove from tidy_data.
#' @return list with 2 elements:
#' holdout_set : data frame with AIS info from offenders before/after
#' the year of offense, potential offenders and known non offenders;
#' training set : data frame with AIS info from offenders during the year
#' of offense, and unlabeled cases
#'
#' @import dplyr
#' @importFrom forcats fct_relevel
#' @importFrom tidyselect all_of
#' @importFrom forcats fct_relevel
#'
#' @export
#'
utils::globalVariables("where")    #<---- Adding this here

ml_prep_data <- function(fl_data,
                           tidy_data,
                           gears_interest, vars_to_factor, vars_remove) {

...
natemiller commented 2 years ago

Note.. I think you'll have to make sure you import utils if you try this option.

natemiller commented 2 years ago

@rociojoo I am also noticing in running this a second time some missing dependencies for ranger, themis, tune, and tictoc. themis and tune appear to be in the NAMESPACE (at least some functions from each package), but tictoc and ranger are not.

rociojoo commented 2 years ago

The parallelly typo was fixed. Thank you.

rociojoo commented 2 years ago

The suggestion with utils for where did not work.

rociojoo commented 2 years ago

@natemiller I added tictoc and ranger in Suggests in the Description file. The problem is that in theory, these two packages are only called in the script to do the analyses, but not needed in any of the actual functions of the package. So in theory, one would not necessarily want to know how long it takes to run something, or decide not to use random forests from ranger but something else as an engine. I don't know what to do with that.