Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8649167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:29:35+00:00 2026-06-12T13:29:35+00:00

In the documentation for the .C function in R here , it says that

  • 0

In the documentation for the .C function in R here, it says that the C function itself must be of return type void. I’m working on some inherited code that uses the .C function (rather than .Call or Rcpp), but I’d like to write a function that “returns” a vector of unknown size. If I knew the size of this vector, I could allocate it in R and pass the pointer to C, whose contents can then be modified. Given that I don’t know its size, what is the way to declare it in R? I imagine it will have this shape, but I don’t know the details:

output <- ?????
storage.mode(a) <- "integer"
tmp <- .C("myfunc",a,output)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:29:36+00:00Added an answer on June 12, 2026 at 1:29 pm

    I suggest you do use .Call() instead of .C() — see recent discussions on the r-devel list. I conjecture that you will find close to no experienced R developers suggesting to use .C() for new projects.

    Here is a simple illustration. You are by no means forced to use Rcpp, the same code can be written in the plain C API as well, albeit not as compactly:

    R> fx <- rcpp(signature(sn="integer"), body='   // rcpp() is from inline 0.3.10
    +    int size = as<int>(sn);
    +    IntegerVector v(size); 
    +    for (int i=0; i<size; i++) v[i] = i;
    +    return(v); 
    + ') 
    R> fx(3) 
    [1] 0 1 2   
    R> fx(7) 
    [1] 0 1 2 3 4 5 6  
    R>
    

    In the old .C() interface, you can only return atomistic C types like *int or *double and you cannot allocate space at the C level as you can only “mark” SEXP object for management by R when you can actually return SEXP objects — and only .Call() can.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ColdFusion's documentation for the valuelist function says that it does NOT evaluate the values,
In the documentation for Leaflet here: http://leafletjs.com/reference-1.2.0.html#circlemarker it says that CircleMaker extends Circle, and
JS Newb here. I'm working with a function, and the documentation for said function
I have been unable to find any decent documentation on this function. The code
The Python 2 documentation says: Built-in Functions: map(function, iterable, ...) Apply function to every
AS3 documentation says that Strings in AS3 are in UTF-16 format. There is a
The documentation for jQuery's :selected selector says that the proper way to use it
There is HTML page with contents like this. Documentation at MDN says that childNodes
I'm trying to validate user input by using the QString::toDouble() function. The documentation says
I have a lot of code that uses C style variable arguments. The code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.