Open stephematician opened 1 year ago
hi,I met a problem in laerning R ,can you give me some help? My question link is : How to pass parameters in .R file to cpp11 function in .cpp file
thank you very much if you can lend me some time!
hi,I met a problem in laerning R ,can you give me some help? My question link is : How to pass parameters in .R file to cpp11 function in .cpp file
thank you very much if you can lend me some time!
I don't know if you did, but I would try https://www.stackoverflow.com to post problems like this.
thank you for your help. Finally i got the solution –—— n <- sum(c(1.1,2.2,3.5)) use c(...) to pass vector of numbers
---- Replied Message ----
| From | @.> |
| Date | 04/15/2023 07:27 |
| To | @.> |
| Cc | @.>@.> |
| Subject | Re: [r-lib/cpp11] Unclear error when r_string
is used as an argument (Issue #311) |
hi,I met a problem in laerning R ,can you give me some help? My question link is : How to pass parameters in .R file to cpp11 function in .cpp file
thank you very much if you can lend me some time!
I don't know if you did, but I would try https://www.stackoverflow.com to post problems like this.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
I know why this doesn't work; however it took a while to track down (and I didn't find help elsewhere) - so at least if I put this here it might help others.
Basic idea is what if you want to pass a 'scalar' character vector (i.e. invoke a function in R like
foo("test")
), it looks like the pattern I have to use is:No problems.
On the other hand, trying this (and hoping that cpp11 does the hard work) fails:
As a suggestion, perhaps have a valid_type check on the data similar to
r_vector
; e.g.