Re: [Rd] Demo for linking native routines between R packages

2021-01-09 Thread Gábor Csárdi
On Sat, Jan 9, 2021 at 4:45 PM Joshua Ulrich 
wrote:
[...]

>
> That said, WRE does list two packages that register native routines
> from other packages:
>
> https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Linking-to-native-routines-in-other-packages
>
>
There are a bunch more, see here:
https://github.com/search?q=org%3Acran+R_RegisterCCallable=code

Here is another very minimal example:
https://github.com/DavisVaughan/cexport#cexport

Gabor

[...]

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2021-01-09 Thread Joshua Ulrich
Hi David,

On Wed, Jan 6, 2021 at 4:00 AM Jitao David Zhang  wrote:
>
> Dear Davis, Dirk, Jan, and r-devel subscribers,
>
> I hope you have had a good start in the new year.
>
> For your information: I have updated the GitHub repository to demonstrate
> linking native routines between R packages (
> https://github.com/Accio/demo-linking-native), especially by listing the
> prior art and the project by Davis to give the readers more background and
> history of the topic. And I took the liberty to acknowledge your
> contribution, criticism and help to improve this baby project.
>
> In any case, I wish there is a link from WRE to a small demo (not
> necessarily mine!) where linking native routine is implemented in a
> minimalistic example for teaching and demonstration purposes. That will
> help people a lot in my opinion.
>
R-core will probably be reluctant to link to an external example they
have very little control over. For example, what if the process
changes and the external source doesn't get updated?

That said, WRE does list two packages that register native routines
from other packages:
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Linking-to-native-routines-in-other-packages

I'd be open to including a vignette in xts that discusses the process
of linking to zoo. That would have the benefit of needing to be
updated if the process changes. We can discuss off-list if you're
interested in collaborating on it.

> Best regards,
> David
>
> --
> Jitao David Zhang
>
> http://jdzhang.me/
> m...@jdzhang.me
>
> Schützengasse 20
> 4125 Riehen, Switzerland
>
> [[alternative HTML version deleted]]
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2021-01-06 Thread Jitao David Zhang
Dear Davis, Dirk, Jan, and r-devel subscribers,

I hope you have had a good start in the new year.

For your information: I have updated the GitHub repository to demonstrate
linking native routines between R packages (
https://github.com/Accio/demo-linking-native), especially by listing the
prior art and the project by Davis to give the readers more background and
history of the topic. And I took the liberty to acknowledge your
contribution, criticism and help to improve this baby project.

In any case, I wish there is a link from WRE to a small demo (not
necessarily mine!) where linking native routine is implemented in a
minimalistic example for teaching and demonstration purposes. That will
help people a lot in my opinion.

Best regards,
David

-- 
Jitao David Zhang

http://jdzhang.me/
m...@jdzhang.me

Schützengasse 20
4125 Riehen, Switzerland

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2020-04-17 Thread Jan Gorecki
Dirk, Thank you for a comprehensive set of resources on that.

Yet, I think the proposal here make sense.
Packages you mentioned are real-life package. It would be way easier
to learn from a package that is meant to only show this single thing.
For the same reason I think it also make sense to have a "hello world
from C" package linked from WRE. All those native routines
registration, the proper way, is not really that obvious. It would be
much easier to learn from a package that doesn't have any other logic.

Best wishes,
Jan Gorecki

On Fri, Apr 17, 2020 at 3:32 PM Zhang, Jitao David via R-devel
 wrote:
>
> Dear Davis and Dirk,
>
> Thank you very much for the suggestions, which are very valuable and
> helpful.
>
> I will add references to prior examples, document my project with the clear
> step-by-step-style document of Davis's project, and come back again to the
> mailing list.
>
> Best wishes,
> David
>
> On Fri, Apr 17, 2020 at 3:40 PM Dirk Eddelbuettel  wrote:
>
> >
> > Jitao,
> >
> > Thanks for writing this up.
> >
> > You could add a section on 'prior art' and references.  The canonical
> > example
> > always was (c.f. Writing R Extensions)
> >
> >   lme4 <-> Matrix
> >
> > which was followed early by the CRAN packages
> >
> >   zoo <-> xts
> >
> > upon which I built
> >
> >   xts <-> RcppXts
> >
> > with a write-up (from 2013 !!) here:
> > https://gallery.rcpp.org/articles/accessing-xts-api/
> >
> > Via private mail, I helped then-maintainer Vincent connect expm:
> >
> >   expm <-> Matrix
> >
> > and built two packages on CRAN _for the very purpose of exporting API
> > functions to be called_ (which in both cases are from base R as R Core is
> > very careful not get tied into exporting APIs, which is both understandable
> > and a source of added difficulty for us package writers)
> >
> >   RApiDatetime
> >   RApiSerialize
> >
> > The latter one is use by my RcppRedis package, Travers' very nice qs
> > package
> > and Tim's rpg package.
> >
> > To my reading, the R Community is drifting more and more towards collective
> > amnesia where prior work is (pick any one the following)
> >
> >  - ignored altogether
> >  - reinvented by another package
> >  - shadowed by another package
> >
> > rather than extended, improved and/or cited.  That is a collective loss for
> > all of us. It would be nice if you could stear back a little and reference
> > prior related work. My apologies to other packages in this area I have not
> > listed. We really should have a common reference for this.
> >
> > Cheers, Dirk
> >
> > --
> > http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
> >
>
>
> --
>
> *Dr. Jitao David Zhang | 张继涛 | A Computational Biologist in Drug Discovery*
>
> *Building 93/3.38, **Tel +41 61 688 62 51*
>
> *Roche Pharmaceutical Research and Early Development
> (pRED) | Pharmaceutical Sciences, BiOmics, BEDA (see 
> http://**go.roche.com/BEDA
> **) | Roche Innovation Center Basel | F.
> Hoffmann-La-Roche AG | CH-4070 Basel | Switzerland*
> *Core working hours - No Meetings: Mo/8:30-16:00; Tu/8:30-17:00;
> We/8:30-16:00; Th/9:00-11:30*
> *Available for meetings: Mo/16:00-17:00; We/16:00-17:00**; Th/11:00-17:00;
> Fr/8:00-10:00*
>
> Confidentiality Note: This message is intended only for ...{{dropped:13}}
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2020-04-17 Thread Zhang, Jitao David via R-devel
Dear Davis and Dirk,

Thank you very much for the suggestions, which are very valuable and
helpful.

I will add references to prior examples, document my project with the clear
step-by-step-style document of Davis's project, and come back again to the
mailing list.

Best wishes,
David

On Fri, Apr 17, 2020 at 3:40 PM Dirk Eddelbuettel  wrote:

>
> Jitao,
>
> Thanks for writing this up.
>
> You could add a section on 'prior art' and references.  The canonical
> example
> always was (c.f. Writing R Extensions)
>
>   lme4 <-> Matrix
>
> which was followed early by the CRAN packages
>
>   zoo <-> xts
>
> upon which I built
>
>   xts <-> RcppXts
>
> with a write-up (from 2013 !!) here:
> https://gallery.rcpp.org/articles/accessing-xts-api/
>
> Via private mail, I helped then-maintainer Vincent connect expm:
>
>   expm <-> Matrix
>
> and built two packages on CRAN _for the very purpose of exporting API
> functions to be called_ (which in both cases are from base R as R Core is
> very careful not get tied into exporting APIs, which is both understandable
> and a source of added difficulty for us package writers)
>
>   RApiDatetime
>   RApiSerialize
>
> The latter one is use by my RcppRedis package, Travers' very nice qs
> package
> and Tim's rpg package.
>
> To my reading, the R Community is drifting more and more towards collective
> amnesia where prior work is (pick any one the following)
>
>  - ignored altogether
>  - reinvented by another package
>  - shadowed by another package
>
> rather than extended, improved and/or cited.  That is a collective loss for
> all of us. It would be nice if you could stear back a little and reference
> prior related work. My apologies to other packages in this area I have not
> listed. We really should have a common reference for this.
>
> Cheers, Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
>


-- 

*Dr. Jitao David Zhang | 张继涛 | A Computational Biologist in Drug Discovery*

*Building 93/3.38, **Tel +41 61 688 62 51*

*Roche Pharmaceutical Research and Early Development
(pRED) | Pharmaceutical Sciences, BiOmics, BEDA (see http://**go.roche.com/BEDA
**) | Roche Innovation Center Basel | F.
Hoffmann-La-Roche AG | CH-4070 Basel | Switzerland*
*Core working hours - No Meetings: Mo/8:30-16:00; Tu/8:30-17:00;
We/8:30-16:00; Th/9:00-11:30*
*Available for meetings: Mo/16:00-17:00; We/16:00-17:00**; Th/11:00-17:00;
Fr/8:00-10:00*

Confidentiality Note: This message is intended only for ...{{dropped:13}}

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2020-04-17 Thread Davis Vaughan
I tried to do this a little. I mentioned xts along with:
bdsmatrix https://github.com/cran/bdsmatrix
cleancall https://github.com/r-lib/cleancall/

On Fri, Apr 17, 2020 at 9:40 AM Dirk Eddelbuettel  wrote:

>
> Jitao,
>
> Thanks for writing this up.
>
> You could add a section on 'prior art' and references.  The canonical
> example
> always was (c.f. Writing R Extensions)
>
>   lme4 <-> Matrix
>
> which was followed early by the CRAN packages
>
>   zoo <-> xts
>
> upon which I built
>
>   xts <-> RcppXts
>
> with a write-up (from 2013 !!) here:
> https://gallery.rcpp.org/articles/accessing-xts-api/
>
> Via private mail, I helped then-maintainer Vincent connect expm:
>
>   expm <-> Matrix
>
> and built two packages on CRAN _for the very purpose of exporting API
> functions to be called_ (which in both cases are from base R as R Core is
> very careful not get tied into exporting APIs, which is both understandable
> and a source of added difficulty for us package writers)
>
>   RApiDatetime
>   RApiSerialize
>
> The latter one is use by my RcppRedis package, Travers' very nice qs
> package
> and Tim's rpg package.
>
> To my reading, the R Community is drifting more and more towards collective
> amnesia where prior work is (pick any one the following)
>
>  - ignored altogether
>  - reinvented by another package
>  - shadowed by another package
>
> rather than extended, improved and/or cited.  That is a collective loss for
> all of us. It would be nice if you could stear back a little and reference
> prior related work. My apologies to other packages in this area I have not
> listed. We really should have a common reference for this.
>
> Cheers, Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2020-04-17 Thread Dirk Eddelbuettel


Jitao,

Thanks for writing this up.

You could add a section on 'prior art' and references.  The canonical example
always was (c.f. Writing R Extensions)

  lme4 <-> Matrix

which was followed early by the CRAN packages

  zoo <-> xts
  
upon which I built

  xts <-> RcppXts
  
with a write-up (from 2013 !!) here: 
https://gallery.rcpp.org/articles/accessing-xts-api/

Via private mail, I helped then-maintainer Vincent connect expm:

  expm <-> Matrix

and built two packages on CRAN _for the very purpose of exporting API
functions to be called_ (which in both cases are from base R as R Core is
very careful not get tied into exporting APIs, which is both understandable
and a source of added difficulty for us package writers)

  RApiDatetime
  RApiSerialize

The latter one is use by my RcppRedis package, Travers' very nice qs package
and Tim's rpg package.

To my reading, the R Community is drifting more and more towards collective
amnesia where prior work is (pick any one the following)

 - ignored altogether
 - reinvented by another package
 - shadowed by another package
 
rather than extended, improved and/or cited.  That is a collective loss for
all of us. It would be nice if you could stear back a little and reference
prior related work. My apologies to other packages in this area I have not
listed. We really should have a common reference for this.

Cheers, Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2020-04-17 Thread Zhang, Jitao David via R-devel
Dear Davis,

Thank you a lot for sharing this, and I am happy that I was not the only
one who need to do it once to learn:)

I proposed to add my repo to the manual. I think it makes sense to add both
of ours, if possible, or we could merge them together and add that to the
manual.

Long-term URL stability is apparently an issue, but I think we may find a
solution there.

Anyway, thanks a lot for sharing!

Best wishes,
David

On Fri, Apr 17, 2020 at 3:12 PM Davis Vaughan  wrote:

> Nice David! I also wrote up something similar a little while back
> https://github.com/DavisVaughan/cexport
>
> -Davis
>
> On Fri, Apr 17, 2020 at 7:09 AM Zhang, Jitao David via R-devel <
> r-devel@r-project.org> wrote:
>
>> Dear R developers,
>>
>> I want to advertise a small project for the educational purpose to show
>> people how to link native routines.
>>
>> In R programming, we need to link to native routines in C, C++, or Fortran
>> from the R environment. In most cases, the linking works within one
>> package, namely the R code in a package calls the native code in the same
>> package.
>>
>> This is not necessarily always the case. Sometimes, a piece of C or R code
>> in a package needs to link to native routines in another R package.
>> The *Writing
>> R Extensions manual describes *how to do this in the section *Linking to
>> native routines in other packages*. However, some details were not clear
>> to
>> me, and I could find no demo dedicated to this purpose.
>>
>> Therefore, I decided to build a demo that is available at my Github
>> repository Accio/demo-linking-native
>> . Besides implementing the
>> linking of native routines between R packages, the project also documents
>> issues that I met and how I solved them.
>>
>> In case you find the demo useful or you have suggestions on how to improve
>> it, please let me know. I wonder whether you think it is a good idea to
>> suggest to the core team to add the project to the manual so that other
>> people can understand the process better with the demo.
>>
>> In case of questions, let me know.
>>
>> Best wishes,
>> David
>>
>> --
>>
>> *Dr. Jitao David Zhang | 张继涛 | A Computational Biologist in Drug
>> Discovery*
>>
>> *Building 93/3.38, **Tel +41 61 688 62 51*
>>
>> *Roche Pharmaceutical Research and Early Development
>> (pRED) | Pharmaceutical Sciences, BiOmics, BEDA (see http://**
>> go.roche.com/BEDA
>> **) | Roche Innovation Center Basel | F.
>> Hoffmann-La-Roche AG | CH-4070 Basel | Switzerland*
>> *Core working hours - No Meetings: Mo/8:30-16:00; Tu/8:30-17:00;
>> We/8:30-16:00; Th/9:00-11:30*
>> *Available for meetings: Mo/16:00-17:00; We/16:00-17:00**; Th/11:00-17:00;
>> Fr/8:00-10:00*
>>
>> Confidentiality Note: This message is intended only for ...{{dropped:13}}
>>
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

-- 

*Dr. Jitao David Zhang | 张继涛 | A Computational Biologist in Drug Discovery*

*Building 93/3.38, **Tel +41 61 688 62 51*

*Roche Pharmaceutical Research and Early Development
(pRED) | Pharmaceutical Sciences, BiOmics, BEDA (see http://**go.roche.com/BEDA
**) | Roche Innovation Center Basel | F.
Hoffmann-La-Roche AG | CH-4070 Basel | Switzerland*
*Core working hours - No Meetings: Mo/8:30-16:00; Tu/8:30-17:00;
We/8:30-16:00; Th/9:00-11:30*
*Available for meetings: Mo/16:00-17:00; We/16:00-17:00**; Th/11:00-17:00;
Fr/8:00-10:00*

Confidentiality Note: This message is intended only for ...{{dropped:13}}

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Demo for linking native routines between R packages

2020-04-17 Thread Davis Vaughan
Nice David! I also wrote up something similar a little while back
https://github.com/DavisVaughan/cexport

-Davis

On Fri, Apr 17, 2020 at 7:09 AM Zhang, Jitao David via R-devel <
r-devel@r-project.org> wrote:

> Dear R developers,
>
> I want to advertise a small project for the educational purpose to show
> people how to link native routines.
>
> In R programming, we need to link to native routines in C, C++, or Fortran
> from the R environment. In most cases, the linking works within one
> package, namely the R code in a package calls the native code in the same
> package.
>
> This is not necessarily always the case. Sometimes, a piece of C or R code
> in a package needs to link to native routines in another R package.
> The *Writing
> R Extensions manual describes *how to do this in the section *Linking to
> native routines in other packages*. However, some details were not clear to
> me, and I could find no demo dedicated to this purpose.
>
> Therefore, I decided to build a demo that is available at my Github
> repository Accio/demo-linking-native
> . Besides implementing the
> linking of native routines between R packages, the project also documents
> issues that I met and how I solved them.
>
> In case you find the demo useful or you have suggestions on how to improve
> it, please let me know. I wonder whether you think it is a good idea to
> suggest to the core team to add the project to the manual so that other
> people can understand the process better with the demo.
>
> In case of questions, let me know.
>
> Best wishes,
> David
>
> --
>
> *Dr. Jitao David Zhang | 张继涛 | A Computational Biologist in Drug Discovery*
>
> *Building 93/3.38, **Tel +41 61 688 62 51*
>
> *Roche Pharmaceutical Research and Early Development
> (pRED) | Pharmaceutical Sciences, BiOmics, BEDA (see http://**
> go.roche.com/BEDA
> **) | Roche Innovation Center Basel | F.
> Hoffmann-La-Roche AG | CH-4070 Basel | Switzerland*
> *Core working hours - No Meetings: Mo/8:30-16:00; Tu/8:30-17:00;
> We/8:30-16:00; Th/9:00-11:30*
> *Available for meetings: Mo/16:00-17:00; We/16:00-17:00**; Th/11:00-17:00;
> Fr/8:00-10:00*
>
> Confidentiality Note: This message is intended only for ...{{dropped:13}}
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Demo for linking native routines between R packages

2020-04-17 Thread Zhang, Jitao David via R-devel
Dear R developers,

I want to advertise a small project for the educational purpose to show
people how to link native routines.

In R programming, we need to link to native routines in C, C++, or Fortran
from the R environment. In most cases, the linking works within one
package, namely the R code in a package calls the native code in the same
package.

This is not necessarily always the case. Sometimes, a piece of C or R code
in a package needs to link to native routines in another R package.
The *Writing
R Extensions manual describes *how to do this in the section *Linking to
native routines in other packages*. However, some details were not clear to
me, and I could find no demo dedicated to this purpose.

Therefore, I decided to build a demo that is available at my Github
repository Accio/demo-linking-native
. Besides implementing the
linking of native routines between R packages, the project also documents
issues that I met and how I solved them.

In case you find the demo useful or you have suggestions on how to improve
it, please let me know. I wonder whether you think it is a good idea to
suggest to the core team to add the project to the manual so that other
people can understand the process better with the demo.

In case of questions, let me know.

Best wishes,
David

-- 

*Dr. Jitao David Zhang | 张继涛 | A Computational Biologist in Drug Discovery*

*Building 93/3.38, **Tel +41 61 688 62 51*

*Roche Pharmaceutical Research and Early Development
(pRED) | Pharmaceutical Sciences, BiOmics, BEDA (see http://**go.roche.com/BEDA
**) | Roche Innovation Center Basel | F.
Hoffmann-La-Roche AG | CH-4070 Basel | Switzerland*
*Core working hours - No Meetings: Mo/8:30-16:00; Tu/8:30-17:00;
We/8:30-16:00; Th/9:00-11:30*
*Available for meetings: Mo/16:00-17:00; We/16:00-17:00**; Th/11:00-17:00;
Fr/8:00-10:00*

Confidentiality Note: This message is intended only for ...{{dropped:13}}

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel