You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is important because, as in the model and package developed for a client, a package may be used to run lots of the generic code (which can make up a high proportion of the model) and then what is left for the model visualisation is actually a smaller subset of model code.
Potential fix:
renv::dependencies() provides a table of dependencies by file path.
We can adapt and run by function! This will give external dependency list for each function.
Then, for set functions we could load the arguments and body. It won't be possible to load the full code with Roxygen because this may be stored somewhere else.
Note: we won't always want full function by function dependencies as this will be massive, in most cases we will just want a list of packages used.
The text was updated successfully, but these errors were encountered:
#' @title Identify the package of a function call
#'
#' @param id the id of the function call in the parsed code
#' @param df_ParsedData a dataframe of the parsed code
#'
#' @return
#' @export
#'
#' @examples
identify_SYMBOL_PACKAGE <- function(id, df_ParsedData){
# get the parent of the function call
parent_of_foo <- df_ParsedData$parent[which(df_ParsedData$id == id)]
# get the package name if there is one
package <- df_ParsedData$text[df_ParsedData$parent == parent_of_foo & df_ParsedData$token=="SYMBOL_PACKAGE"]
# else find the package from environment
if(length(package) == 0) package <- find(what = df_ParsedData$text[df_ParsedData$id == id])[1]
# remove the text 'package:' from the object if it exists
package <- gsub("package:", "", package)
return(package)
}
This is important because, as in the model and package developed for a client, a package may be used to run lots of the generic code (which can make up a high proportion of the model) and then what is left for the model visualisation is actually a smaller subset of model code.
Potential fix:
renv::dependencies()
provides a table of dependencies by file path.We can adapt and run by function! This will give external dependency list for each function.
Then, for set functions we could load the arguments and body. It won't be possible to load the full code with Roxygen because this may be stored somewhere else.
Note: we won't always want full function by function dependencies as this will be massive, in most cases we will just want a list of packages used.
The text was updated successfully, but these errors were encountered: