Skip to content

Commit

Permalink
Use invisible to turn off output
Browse files Browse the repository at this point in the history
Instead of relying on R-function to return invisible object,
explicitely return the fitted object but make it invisible
  • Loading branch information
Dhairya Jain committed Oct 30, 2023
1 parent b2f2486 commit b509f72
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions R/SFM.fit.models.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ SFM.fit.models <- function(Ra, Rb, Rf=0, family = "mopt",
# option is that program will ask you to choose a plot
# plots: Boolean to output plots after the function. Defaults to TRUE
# Output:
# Graphs comparing models, If plots = TRUE is used
# A fitted object, If plots = FALSE is used
# Graphs comparing models & a fitted object is returned, If plots = TRUE is used
# Only a fitted object is returned, If plots = FALSE is used

# FUNCTION:

Expand Down Expand Up @@ -108,14 +108,17 @@ SFM.fit.models <- function(Ra, Rb, Rf=0, family = "mopt",
# Fit both the models
fmLSrob <- fit.models::fit.models(LSFit, RobFit)

# Plot the fit.models object if asked and function will return nothing
# Plot the fit.models object if asked
if (plots==TRUE){
if(is.null(which.plots)){
plot(fmLSrob, which.plots = "ask") # ask = 0 to exit
}
else {
plot(fmLSrob, which.plots = which.plots)
}

# Return the fitted object, but make it invisible
return (invisible(fmLSrob));
}

else{
Expand Down

0 comments on commit b509f72

Please sign in to comment.