Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient and recursive way to navigate through R code on Rstudio?

Tags:

r

ide

rstudio

I am using RStudio.

I'm starting to feel the need to go through packges code to deeper understanding or hack certains functions. When I try to navigate using Using Ctrl+Click with the mouse For functions defined within packages the code is displayed in a special Source Viewer.

The problem of this view

  1. It is read only view(why?). You can't go to through the code of functions called and defined else. I know other IDE (for other languages) where we can go through the code recursively in read only-mode.
  2. For generic function , we have only the UseMethod line without the code.

My solution was is to load the package(code source) and to go through the code using the Find in files option.

Do you have more efficient method to go respectively through the code? I am open to suggestions: other IDE? Windows/unix? network solution: Do you think it is possible to install Rstudio server version on the cloud to go through all R package without loading?

PS : My question is mainly about going through the code not hacking it.

like image 871
agstudy Avatar asked Dec 03 '12 05:12

agstudy


People also ask

Can you do recursive functions in R?

It exploits the basic working of functions in R. Recursion is when the function calls itself. This forms a loop, where every time the function is called, it calls itself again and again and this technique is known as recursion. Since the loops increase the memory we use the recursion.

What is recursive list in R?

Lists can be recursive, meaning that you can have lists within lists. Here's an example: > b <- list(u = 5, v = 12) > c <- list(w = 13) > a <- list(b,c) > a [[1]] [[1]]$u [1] 5 [[1]]$v [1] 12 [[2]] [[2]]$w [1] 13 > length(a) [1] 2.


1 Answers

I generally find github to be the best way to dig into packages (for those posted there). While this is far from a perfect solution, it often also includes the tests and links to additional documentation that you don't always find with the standard "?". This approach is generally most useful if you need to truly grok a package, rather than simply understanding a poorly documented signature. Hadley Wickham's lubridate is a package where this approach paid off for me. Additionally, I find I get a better sense of the quality of the code from examining the tests and ancillary files.

like image 66
Ed Fine Avatar answered Sep 21 '22 13:09

Ed Fine