How do I track down where a R package function fails? [duplicate] - debugging

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
General suggestions for debugging R?
I've encountered an error when calling a function from an R package. Briefly,
> library(treemap)
> ...
> tmPlot(X,index=c("r1","r2","r3","r4"),vSize="size")
Error in if (maxI == 1) { : missing value where TRUE/FALSE needed
This SO question gives more details.
I examined the source code of tmPlot by typing tmPlot at the R prompt, but the line that fails doesn't appear in the function. Which means, I assume, that it's failing in some function called by tmPlot.
What's the best way to track this down? For example, can I generate a stack trace somehow? Is there an interactive debugger that will allow me to step through and see where the error happens?

traceback will print the call stack.
traceback()
Also, have a look at the on-line help for the debug function. Although I have seen better interactive debuggers, there is some basic functionality provided by debug(), debugonce() and undebug()
?base::debug

Related

Swift 6 Error: Expression requiring global actor 'MainActor' cannot appear in default-value expression of property '_api' [duplicate]

This question already has answers here:
How do I fix "Expression requiring global actor 'MainActor' cannot appear in default-value expression of property '_audioPlaybackManager'"?
(2 answers)
Closed 11 months ago.
Xcode keeps throwing a complier error that it doesn't comply with Swift 6 Which isn't obv out yet. It only started when I downloaded 13.3 Xcode.
The error reads:
Expression requiring global actor 'MainActor' cannot appear in default-value expression of property '_api'; this is an error in Swift 6
my code is doing an state object call like so:
#StateObject var api = RecipeAPI()
I have debugged and closed and reopened everything but nothing changes. Reported it to apple too.
Best,
Imran
That's a warning in Swift 5. In Swift 6, it'll be an error. It's suggesting that you fix it now, but in the future it'll break the build. You're requiring that everything (including the init be run on the MainActor, but this assignment isn't promised to run on the MainActor itself (possibly because the type it's part of isn't also marked #MainActor). You may find a lot of these in 5.6 that are extremely difficult to fix. They're still tuning the warnings. (So when you start to formulate your next question "how do I eliminate all Swift concurrency warnings when dealing with SwiftUI and Foundation," the answer may be "you can't, or at least not in any easy way." It depends on the exact problem.)

Unbounded Value OCAML [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am trying to compile Orange as part of OTAWA
However I get the below Error in file wcee.ml
Error: Unbound value IMap.print_ordered
The reason for the error is the below snippet.
let glb = common
(** Least upper bound. *)
let lub = IMap.combine max
(** Pretty printer. *)
let print = IMap.print CostItem.print Format.pp_print_int
(** Full printing. *)
let print_complete = IMap.print_ordered ~first:"" ~firstbind:">> " ~last:"" ~sep:"#\n" CostItem.print CostItem.known Format.pp_print_int
end
What is the reason for that ?
TL,DR: at first sight, it might be possible that the project currently just FTBFS (fails to build from source)? Anyway, I didn't attempt to compile it myself, but you may want to get in touch with the TRACES research team that maintains OTAWA to ask? (e.g., emailing Pr. CASSÉ…)
Further details:
the latest version of the source code seems to be online at this URL: wcee.ml,
which depends on tMap.ml,
the function you mention is defined via module IMap = TMap.Make(CostItem), which depends on the Make functor in the tMap compilation unit, which indeed does not seem to provide the print_ordered function,
hence the Unbound value error (which just means "this function is undefined!")

check the about-to-be-returned value in the debugger [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Can I find out the return value before returning while debugging in Visual Studio
VS get returned value in C# code?
In Visual Studio 2010, is there a way to check the value that a method is about to return? I often find myself changing code like:
return myComplexOp(someOtherComplexOp(foo));
to
var ret = myComplexOp(someOtherComplexOp(foo));
return ret;
just to make it easier to debug? Is there an easier way?
With C++ code I am stepping out of the function (Shift + F11) and open Autos window (Debug, Windows, Autos). At this point it shows recently returned value like this:
It's not the most convenient thing, but it's still something. At least you can see the returned value without altering code as mentioned in original post.
If you enable the Registers Windows, you can check EAX which should hold the return value.

Cannot evaluate expression error in ONE project for years

Just tired to see this error every time for years only in ONE project: "Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized"
Almost every property or field displays this message. From vs2005+.net2.0 to vs2008+.net3.5 now. Does anybody know how to fix it?
This is the same problem as this StackOverfow question. In that case it seems to be an inbuilt limit to the size of structs used within the method. The answer here provides links to two discussions of the issue.

Clear R Console programmatically [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Function to Clear the Console in R
Is there a way to invoke the Clear Console (Ctrl+L) menu command programmatically?
I use a function for doing that, and actually have put it in {R directory}\etc\Rprofile.site so that it will always be available for use.
cls <- function() {
require(rcom)
wsh <- comCreateObject("Wscript.Shell")
comInvoke(wsh, "SendKeys", "\014")
invisible(wsh)
}
cls()
To clear the console give
cls()
P.S. The function doesn't work the first time it's called and that's why I invoke the function immediately after declaring it in Rprofile.site. As I recall, you may be asked to install some program, in order for this to work.
Create this function:
cls <- function() cat(rep("\n",100))
Then call it:
cls()
Works with:
Windows
Linux
Mac
I might be missing the point dramatically, but is simple system("clear") an easier approach? Of course, it can only be applied on Linux/Unix environments...

Resources