Home > Back-end >  Error in debugonce function in Rstudio, it returns - argument must be a function
Error in debugonce function in Rstudio, it returns - argument must be a function

Time:01-26

I have this code in R but everytime I run the debug function I get the following message

makes_poly=function(n,u){
  vec=c(1)
  for ( i in 1:n){
    vec[i 1]= u^i
  }
  return(vec)
}
debugonce(makes_poly(2,4))

but everytime I run the debug function I get the following message

Error in debugonce(makes_poly(2, 4)) : argument must be a function

CodePudding user response:

The return value from makes_poly(2,4) is a vector, so you are essentially running debugonce(c(1,4,16)). Try:

debugonce(makes_poly)
  •  Tags:  
  • Related