Trouble with non-conformable arrays

I have an odd error in R.

I have a big function that does a lot of stuff. Inside, I have, essentially, the MWE

check_mul = function(){ 
        S = matrix(runif(100 * 5), 100, 5) 
        Q = rep(1, 100) 
        t = S / Q
        return(t)
} 

This works fine. In my function, it errors, telling me the arrays are non-conformable.

However when I add a browser() command right before the multiplication command, or in a tryCatch block, entering the scope of the function, the multiplication works!

I'm very confused, by all means it should work, and it does, when debugging.

Is there some obvious gotcha I'm missing? What are some next steps I can do to debug?

The bug was unrelated.

It turns out that as_vector is not the same as as.vector. I was using as_vector to debug and find the problem, but i actually wanted as.vector.

maybe your R session got into a bad state, restart ?
can you provide a reprex ? (i.e. of some code that errors if just run, but runs fine when browsed)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.