0

I met a wired situation. After add new code The code cannot knit out.

function_name <- function (...)
{
  output <- if (output_format == "list") {
    evolved.ts
  } else if (output_format == "tsibble") {
    as.tsibble(evolved.ts)
  }
  return(output)
}
Waldi
  • 39,242
  • 6
  • 30
  • 78
  • seems like you have still loaded the old function without the output_format argument. Can you restart R / RStudio, clear workspace, ... ? – Steffen Moritz Sep 01 '20 at 22:48
  • Thank you for trying to help. As update common on post, I have tried restart R. –  Sep 02 '20 at 06:05

1 Answers1

0

You could read the arguments with args <- list(...):

function_name <- function (...)
{
  args <- list(...)
  # Code
  output <- if (args$output_format == "list") {
    evolved.ts
  } else if (output_format == "tsibble") {
    as.tsibble(evolved.ts)
  }
  return(output)
}
Waldi
  • 39,242
  • 6
  • 30
  • 78
  • Thank you for helping Waldi. What common should I write inside ```args<-list(...)```? I originally though ```list``` is what the initial ts data be looks like, which do not need to be defined and ```tsibble``` is a transform of that ts data. Should I write something like ```list(", paste("GA@bestSol[[GA@iter - ", 0:(GA@run - 1), "]]``` –  Sep 01 '20 at 10:47
  • 1
    `args <- list(...)` is the standard R syntax to get whatever ... from call to function_name, see https://www.r-bloggers.com/r-three-dots-ellipsis/ – Waldi Sep 01 '20 at 12:21
  • Hey, get an error said ```E> '...' used in an incorrect context``` –  Sep 01 '20 at 12:42
  • 1
    Could you create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) for this error? – Waldi Sep 01 '20 at 12:47
  • Sure thing. Would you mind see my update post again? Thanks again. –  Sep 01 '20 at 17:04
  • It's very difficult to tell if you don't provide a MRE. I found following doc : https://www.rdocumentation.org/packages/gratis/versions/0.2.0/topics/generate_ts_with_target, and this version of the function doesn't have output_format argument. Which packages are you loading in the Rmarkdown file? – Waldi Sep 01 '20 at 19:16