How to see where in my code a function gets called in RStudio? - r

I'm currenty cleaning up my first big R project and at a point, where I have a lot of functions implemented but I am not sure, which function got called and used by me in an other script and which function got never used. So now I want to get all calls of this function in my project. Is this possible?
I'm using RStudio and a lot of other IDEs I've used got a feature like this, so I was wondering if this is also implemented in RStudio.
I searched the web and stack overflow, but got no answer, so I assume that this is not possible but I wanted to ask, just in case it IS possible but I didn't found the right answer.
Thank you!

Related

Using custom modules in Julia 1.8.2

I have the following module:
module TestModule
export foo
function foo()
return 1
end
end
and a calling script:
using .TestModule
println(foo())
I get the following error:
ERROR: UndefVarError: TestModule not defined
According to the documentation this should work. I know this can be accomplished via include() but I read that this can cause inconsistencies when trying to include the module multiple times. Another way of achieving this seems to be editing the LOAD_PATH but that seems rather inconvenient and also causes the project to not be portable.
I'm wondering if those are the only current solutions to the problem or if there is something better (The two other post regarding this question are 6+ years old and the docs currently state that this is the way to do it, so I wonder if the problem has been fixed by now). Any help is greatly appreciated.
Cheers
I'm closing this thread as it has been tagged a duplicate multiple times now. I conclude from this that there currently is no way of splitting code into multiple local modules while maintaining portability. The canonical way of splitting code into modules is by adding the module paths to the LOAD_PATH (julia push!(LOAD_PATH, "\path\to\module")). Thanks to everyone for the feedback nonetheless!
Edit:
After executing the TestModule file it works for this example (I missed that this was necessary, at least in VSCode). My actual program still produces module-not-found errors but since I'm unable to reproduce them in a simple example I'll try figuring it out myself first.
Another Edit:
Renaming the modules solved the problem. I suppose the names were already taken by public packages. For any reader wondering how to solve this problem without renaming the custom module, please have a look at this documentation
Cheers

Getting a job status update with R

I have a rather simple question that I can't seem to find an answer for.
I essentially want to know if there is code that provide a status for the code we are running. As an example, I am running code that usually takes time and would like to know if the job is 25%-50%-75% complete. This is the kind of features we get with Software from large companies ($$).
Does anyone use anything when working with R?
I use Rstudio if this is pertinent.
Thanks

Fastest way to send multiple http requests in R

You can use multithreading in Python and send lots of http requests, like in this SO question. My question is, is there any easy way to do this in R? I've seen a guide for RCurl here, but I'd prefer a simpler solution if possible. Currently I'm looping through a series of ids, it's be great to send all (or more) of them at once.
That guide to multiple requests in Rcurl looks pretty simple, in fact I'd say it looks simpler to me than the solution to the Python question you've linked. Better yet, the work is already done for you. Most of that guide is going into detail about the advantages of concurrent requests; the method itself is deceptively simple, and is provided for you pre-cooked right at the top of the page.
You can literally cut and paste the code shown at the top of the post into an R script (include library(RCurl) above it), run that code to source the function, then call the function with a single line.
I won't paste the function code here, since you should get that from its author, but once you've sourced that function, their example usage is:
uris = c("http://www.omegahat.org/index.html", "http://www.omegahat.org/RecentActivities.html")
z <- getURIs(uris)
I just did the above on my own computer, and it works perfectly. I'd be surprised if you can find a simpler solution than that.

R how to know if a library is effectively used?

I have a hudge code, and where all the libraries are attached in the begining of the code. Now, I'm cleaning a bit this code, removing parts of it / re-writting other.
I was wondering if there was a way to know if a specific library is used or not by the code (in order to clean the library part too)? I could list, for each library, all the functions that are attached, then search in the code that this function are not called, but it will become long. I could also remove this library and try to run the code, but I don't like this solution (not enough robust).
I'm sorry if the question have already been asked, but so far, I haven't found any solution :(.

Is it possible to get code completion for R in Emacs ESS similar to what is available in Rstudio?

Rstudio has a great code completion feature. It provides a quick view of functions that start with a given string, as well as function and parameter definitions.
ESS is powerful enough, familiar to me, and integrated into Emacs, where I conduct most of my work - so I am hesitant to move, but this feature is making me consider such a move.
Is it possible to integrate this feature into Emacs ESS?
Is there anything similar to this for Emacs ESS?
Any hope that there will be (and if so, how could I support such an effort?)
You do get the completion thanks to the rcompgen package by Deepayan (now "promoted" into base R as part of the utils package). So when I type
lm(
and hit TAB a new buffer opens which gets me the left-hand side of your window above: the available options to the function at hand. I don't think you can show the help directly though.
There is / was also a way to get context-sensitive help in the mini-buffer when typing but I have forgottten how/where that gets turned on.
[EDIT: This is an old answer and auto-complete package dropped out of fashion since then. Please use company-mode instead. It should work by default. Wiki configuration entry is here.]
Recent versions of ESS (> v.12.02) integrate with auto-complete package out of the box (you need not configure anything, just install auto-complete). It provides help on arguments as well as function help. I added detailed instructions to the wiki
Ess-eldoc was also rewritten and from v.12.02 it's active by default, so you don't need to configure anything.
Or maybe we should all use search:
Emacs autocomplete-mode extension for ESS and R
I don't want to be grumpy, I found this few hours ago and I'm still shocked. It works like a charm. Though I still prefer the old-style pop-ups. =)

Resources