[R-pkg-devel] Searching examples in source code

Uwe Ligges ||gge@ @end|ng |rom @t@t|@t|k@tu-dortmund@de
Mon May 9 08:54:25 CEST 2022


... or simply download.packages("pkg", type="source")

Best,
Uwe Ligges

On 08.05.2022 21:21, Ben Bolker wrote:
>    Whenever you install a package from source you'll see a line at the 
> end of the output something like
> 
>  > The downloaded source packages are in
>      ‘/tmp/Rtmp6ZRMH0/downloaded_packages’
> 
> 
> That is, the source tarball is downloaded to a *temporary file* (on most 
> Linux systems, the /tmp directory is cleared when rebooting).
> 
>    You could do something like this (untested!)
> 
> i1 <- installed.packages()
> for (i in seq(nrow(i1)) {
>    m <- i1[i,]
> 
> download.file(sprintf("https://cran.r-project.org/src/contrib/"%s%s.tar.gz", 
> m$Package, m$Version), dest = "tmp.tgz")
>    system("tar zxvf tmp.tgz")
> }
> 
> and then
> 
> find . -name "*.c*" -exec grep -iH foo {} \;
> 
> or
> 
> find . -name "*.R" -exec grep -iH foo {} \;
> 
>   would work.
> 
> 
> On 2022-05-08 3:02 p.m., Ben Engbers wrote:
>>
>>
>> Op 08-05-2022 om 17:55 schreef Iñaki Ucar:
>>> On Sat, 7 May 2022 at 23:25, Ben Engbers <Ben.Engbers using be-logical.nl> 
>>> wrote:
>>>>
>>>> Hi,
>>
>>>> My first question is if there is a useful linux command to search all
>>>> the source code of installed packages on my system.
>>>
>>> Not sure what you mean here. The source code is not copied along with
>>> your installed packages.
>>
>> Uh? I didn't know that. How does the compile process work? Does this 
>> mean that the (C or C++) sources only live in the repository and that 
>> the compile command accesses those files?
>>
>>>> The second question is if there is a command to search all packages at
>>>> https://cran.r-project.org/web/packages/available_packages_by_name.html? 
>>>>
>>>>
>>>> This question is not only relevant to C++ examples. It would also be
>>>> nice if you could search for occurrences of commands in R code.
>>>
>>> There's a read-only mirror of CRAN on GitHub
>>> (https://github.com/cran). Going there and using the search form
>>> (i.e., specifying "org:cran <your_search_here>") is probably the best
>>> bet to find what you're looking for.
>>
>> If I go to that site and enter "org:cran asio" in  the search field, I 
>> am directed to https://github.com/cran/AsioHeaders. That's not what I 
>> am looking for; I am looking for C sources which make use of org:cran 
>> asio.
>>
>> A R-example would be that I was looking for packages which make use of 
>> the "socketConnection" function. Entering socketConnection in the 
>> search form results in "We couldn’t find any repositories matching 
>> 'org:cran socketConnection'". This doesn't help me...
>>
>> Ben
>>>
>>> Iñaki
>> ______________________________________________
>> R-package-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list