[R] Loading C functions into R
Talita Leite
talitaperciano at hotmail.com
Wed Feb 23 01:51:25 CET 2005
Thanx very much! I got to load the program into R with no problem!
Talita Perciano Costa Leite
Graduanda em Ciência da Computação
Universidade Federal de Alagoas - UFAL
Departamento de Tecnologia da Informação - TCI
Construção de Conhecimento por Agrupamento de Dados - CoCADa
>From: "Huntsinger, Reid" <reid_huntsinger at merck.com>
>To: "'Talita Leite'" <talitaperciano at hotmail.com>
>Subject: RE: [R] Loading C functions into R
>Date: Tue, 22 Feb 2005 16:43:21 -0500
>
>In case you didn't get an answer:
>
>.C() works by calling a function in a shared library you've already loaded
>into R. So you need to 1) compile the code into a shared library (DLL) and
>2) load it into R via dyn.load. The function needs to be declared as
>"void";
>it passes results back via pointers passed in. (So you may need to write a
>simple wrapper to use your code.)
>
>.C() passes pointers to the data of the listed R objects to the function
>being called. (So you have to pass things like array dimensions as
>arguments
>as well.) One of those (or more) could be for output, ie, the function
>writes data into the area pointed to. The return value of .C() is a list
>with (copies of) the R objects passed in, possibly modified.
>
>See the "Writing R Extensions" manual for details of .C() and examples.
>Also, "help(.C)" from an R session, and the R source code itself--for
>example have a look at the functions in packages included with R. The file
>"filter.c" in "ts" (I think) is a good example.
>
>Reid Huntsinger
>
>
>-----Original Message-----
>From: r-help-bounces at stat.math.ethz.ch
>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Talita Leite
>Sent: Tuesday, February 22, 2005 9:01 AM
>To: r-help at stat.math.ethz.ch
>Subject: [R] Loading C functions into R
>
>
>Hi everybody,
>
>I have the source of a C program that includes some archives .c and some
>libraries .h. I'm developing a program using R and I want it to load the C
>program I told before. How can I do that? I was looking for some function
>in
>
>R to do that and I found the .C() but I can't understand how it works.
>Somebody could help me?
>
>Thanx,
>
>Talita Perciano Costa Leite
>Graduanda em Ciência da Computação
>Universidade Federal de Alagoas - UFAL
>Departamento de Tecnologia da Informação - TCI
>Construção de Conhecimento por Agrupamento de Dados - CoCADa
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
>http://www.R-project.org/posting-guide.html
>
>
>
>------------------------------------------------------------------------------
>Notice: This e-mail message, together with any attachments, contains
>information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New
>Jersey, USA 08889), and/or its affiliates (which may be known outside the
>United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
>Banyu) that may be confidential, proprietary copyrighted and/or legally
>privileged. It is intended solely for the use of the individual or entity
>named on this message. If you are not the intended recipient, and have
>received this message in error, please notify us immediately by reply
>e-mail and then delete it from your system.
>------------------------------------------------------------------------------
More information about the R-help
mailing list