Questions tagged [r-lib-cpp11]
7 questions
2
votes
1 answer
Setting colnames in R's cpp11
Provided that cpp11 does not provide any "sugar", we need to use attributes.
I am trying to set colnames in a C++ function, as in the next MWE
#include "cpp11.hpp"
using namespace cpp11;
// THIS WORKS
[[cpp11::register]]
doubles…

pachadotdev
- 3,345
- 6
- 33
- 60
1
vote
0 answers
Debug a function that creates a segfault without informative message
I am working in a write of fixest that uses vendoring (i.e., to use it in a server where a lot of people change things constantly)
So far, some of my functions work, but this creates a segfault
devtools::load_all()
gravity_pois = fepois(Euros ~…

pachadotdev
- 3,345
- 6
- 33
- 60
0
votes
0 answers
Double/integer conversion with cpp11
I hope you are well!
This is a code that I prepared and which crashes the R session (https://github.com/pachadotdev/fixest2/blob/cpp11_wip/dev/gdb-debug-4.R). The issue is that the C++ function cpp_get_fe_gnl_() doesn't like the matrix obsCluster,…

pachadotdev
- 3,345
- 6
- 33
- 60
0
votes
2 answers
Overwriting entries from a matrix in cpp11
I have some Rcpp code to fill entries in a matrix, here's a MWE of what it does:
#include
using namespace Rcpp;
void invert_tri(NumericMatrix &M, int K) {
for(int i=0 ; i

pachadotdev
- 3,345
- 6
- 33
- 60
0
votes
1 answer
Set UTF-8 in (R package) cpp11
Update: From @tospig reply, I'm expecting there to be a .set_encoding() method on cpp11::writables::strings, which is a missing feature at the moment. Therefore, now I ask for an equivalent method to set the encoding.
I'm trying to understand a bit…

pachadotdev
- 3,345
- 6
- 33
- 60
-2
votes
1 answer
correct way to load headers to use String (not string) in C++
How can I avoid the error error: ‘String’ does not name a type (String, not string)
I have this MWE that works with Rcpp (this code is called from R via Rcpp)
#include
#include
#include
CharacterVector some_function(String&…

pachadotdev
- 3,345
- 6
- 33
- 60
-2
votes
1 answer
Using for loops with integers in cpp11 code
I'm trying to write a cpp11 (the R package) code for an assignment and I have a problem that doesn't happen with Rcpp (another R package).
Both Rcpp and cpp11 allow to use C++ user defined functions in R. For example, with both of them I can write a…

pachadotdev
- 3,345
- 6
- 33
- 60