R documentation

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

R documentation

Akira
I am currently wrapping a C++ library with SWIG into R.
Since i did it before in Python, it works pretty fine for me.
The R documentation is pretty poor and I could supply some documentation but I have no idea how I should do this. I figured many things out by myself dince many things are similar to Python. But I guess an example typemap etc. would not hurt.
On the other hand I found some bugs, especially with typemaps. I know how to solve them (I manipulate the SWIG generated files with a Python script so they work afterwards), but i don't where I should report them. Actually I do not know if the R part of SWIG is currently under any development at all.

Does anybody have some information for me?
BR Rike
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R documentation

Richard Beare
There are slow and steady developments, but not many of us working on them. Documentation additions are always welcome and should be made to the Doc/Manual folder, and send pull requests via github.

Thanks!

On Fri, Jun 10, 2016 at 10:47 PM, Akira <[hidden email]> wrote:
I am currently wrapping a C++ library with SWIG into R.
Since i did it before in Python, it works pretty fine for me.
The R documentation is pretty poor and I could supply some documentation but
I have no idea how I should do this. I figured many things out by myself
dince many things are similar to Python. But I guess an example typemap etc.
would not hurt.
On the other hand I found some bugs, especially with typemaps. I know how to
solve them (I manipulate the SWIG generated files with a Python script so
they work afterwards), but i don't where I should report them. Actually I do
not know if the R part of SWIG is currently under any development at all.

Does anybody have some information for me?
BR Rike



--
View this message in context: http://swig.10945.n7.nabble.com/R-documentation-tp14783.html
Sent from the swig-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R documentation

William S Fulton
Yes, I'd like to re-iterate that improvements to the documentation via
github pull requests are very welcome, particularly if you have
identified shortcomings as you have.

William

On 10 June 2016 at 22:37, Richard Beare <[hidden email]> wrote:

> There are slow and steady developments, but not many of us working on them.
> Documentation additions are always welcome and should be made to the
> Doc/Manual folder, and send pull requests via github.
>
> Thanks!
>
> On Fri, Jun 10, 2016 at 10:47 PM, Akira <[hidden email]> wrote:
>>
>> I am currently wrapping a C++ library with SWIG into R.
>> Since i did it before in Python, it works pretty fine for me.
>> The R documentation is pretty poor and I could supply some documentation
>> but
>> I have no idea how I should do this. I figured many things out by myself
>> dince many things are similar to Python. But I guess an example typemap
>> etc.
>> would not hurt.
>> On the other hand I found some bugs, especially with typemaps. I know how
>> to
>> solve them (I manipulate the SWIG generated files with a Python script so
>> they work afterwards), but i don't where I should report them. Actually I
>> do
>> not know if the R part of SWIG is currently under any development at all.
>>
>> Does anybody have some information for me?
>> BR Rike
>>
>>
>>
>> --
>> View this message in context:
>> http://swig.10945.n7.nabble.com/R-documentation-tp14783.html
>> Sent from the swig-user mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> What NetFlow Analyzer can do for you? Monitors network bandwidth and
>> traffic
>> patterns at an interface-level. Reveals which users, apps, and protocols
>> are
>> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
>> J-Flow, sFlow and other flows. Make informed decisions using capacity
>> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
>> _______________________________________________
>> Swig-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/swig-user
>
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> _______________________________________________
> Swig-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/swig-user
>

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R documentation

Akira
So I will do some documentation on typemaps.
I saw it's in html. Since I am not fluent in html, I have to take a little time for this. I hope i have time during the weekend.

The problem I found in using typemaps in R is the following:
I made a typemap(out) to transform the output from an C++ container class to a R list.
So this is my typemap:

%typemap(out) ContainerClass
{
   SEXP dfm, df, data1, data2, entry_names;
   df =  PROTECT(allocVector(VECSXP, 2));

   PROTECT(data1 = allocVector(STRSXP,1));
   PROTECT(data2 = allocVector(STRSXP,1));
   PROTECT(entry_names = allocVector(STRSXP,2));

   SET_STRING_ELT(entry_names,0,mkChar("data1"));
   SET_STRING_ELT(entry_names,1,mkChar("data2"));

   SET_STRING_ELT(data1,0,mkChar($1.data1.get()));
   SET_STRING_ELT(data2,0,mkChar($1.data2.get()));

   SET_VECTOR_ELT(df,0,data1);
   SET_VECTOR_ELT(df,1,data2);
   setAttrib(df,R_NamesSymbol,entry_names);

   UNPROTECT(4);

   dfm = PROTECT(lang2(install("as.list"),df));
   $result = PROTECT(eval(dfm,R_GlobalEnv));

   UNPROTECT(2);
}

This produces the <modulname>_wrap.cpp correctly, but it does not change the <modulname>.R file.
This means that there are the following lines:

[...]
;ans = .Call('R_swig_function_with_typemap', self, data, PACKAGE='modulname');
  ans <- new("_p_ContainerClass", ref=ans) ;
 
  ans
 
}

attr(`R_swig_function_with_typemap`, 'returnType') = '_p_ContainerClass'
[...]

instead of:

[...]
;ans = .Call('R_swig_function_with_typemap', self, data, PACKAGE='modulname');
  ans
 
}

attr(`R_swig_function_with_typemap`, 'returnType') = 'list'
[...]


So I just wrote a script that makes this changes manualy... I do not know if I used SWIG wrong, but in Python the typemap (with the corresponding Python calls, of course) works perfectly fine.

BR Rike
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: R documentation

Richard Beare
A few notes that might help.

C++ stl vectors of strings and numeric types  translate automatically between R and C++ code, so life is simpler if you can use them.

If you want to turn off the last stage of R wrapping, which I think is what you want from the example above, you probably want to look at the rtype and scoerce out definitions. You might want them to be empty for container class:

%typemap("rtype") ContainerClass "list";
%typemap("scoerceout") ContainerClass %{ %}
 
Or similar.

Hope that helps

On Tue, Jun 14, 2016 at 9:48 PM, Akira <[hidden email]> wrote:
So I will do some documentation on typemaps.
I saw it's in html. Since I am not fluent in html, I have to take a little
time for this. I hope i have time during the weekend.

The problem I found in using typemaps in R is the following:
I made a typemap(out) to transform the output from an C++ container class to
a R list.
So this is my typemap:

%typemap(out) ContainerClass
{
   SEXP dfm, df, data1, data2, entry_names;
   df =  PROTECT(allocVector(VECSXP, 2));

   PROTECT(data1 = allocVector(STRSXP,1));
   PROTECT(data2 = allocVector(STRSXP,1));
   PROTECT(entry_names = allocVector(STRSXP,2));

   SET_STRING_ELT(entry_names,0,mkChar("data1"));
   SET_STRING_ELT(entry_names,1,mkChar("data2"));

   SET_STRING_ELT(data1,0,mkChar($1.data1.get()));
   SET_STRING_ELT(data2,0,mkChar($1.data2.get()));

   SET_VECTOR_ELT(df,0,data1);
   SET_VECTOR_ELT(df,1,data2);
   setAttrib(df,R_NamesSymbol,entry_names);

   UNPROTECT(4);

   dfm = PROTECT(lang2(install("as.list"),df));
   $result = PROTECT(eval(dfm,R_GlobalEnv));

   UNPROTECT(2);
}

This produces the <modulname>_wrap.cpp correctly, but it does not change the
<modulname>.R file.
This means that there are the following lines:

[...]
;ans = .Call('R_swig_function_with_typemap', self, data,
PACKAGE='modulname');
  ans <- new("_p_ContainerClass", ref=ans) ;

  ans

}

attr(`R_swig_function_with_typemap`, 'returnType') = '_p_ContainerClass'
[...]

instead of:

[...]
;ans = .Call('R_swig_function_with_typemap', self, data,
PACKAGE='modulname');
  ans

}

attr(`R_swig_function_with_typemap`, 'returnType') = 'list'
[...]


So I just wrote a script that makes this changes manualy... I do not know if
I used SWIG wrong, but in Python the typemap (with the corresponding Python
calls, of course) works perfectly fine.

BR Rike



--
View this message in context: http://swig.10945.n7.nabble.com/R-documentation-tp14783p14797.html
Sent from the swig-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...