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 6788091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:26:36+00:00 2026-05-26T17:26:36+00:00

I’m making calls to C functions from R using R’s .Call interface. Some of

  • 0

I’m making calls to C functions from R using R’s .Call interface. Some of the objects I am passing have custom attributes attached to them, and I want to access these attributes from C without having to pass them as separate arguments to the .Call function.

For example, consider the simple case of a real number with a custom string attribute:

x <- 1
attr(x, "myname") <- "Abiel"

One way to get at the “myname” attribute from within the C function is to pass it as a separate argument:

.Call("test", x, as.character(attr(x, "myname")))

But, I would rather just do

.Call("test", x)

and then recover the “myname” attribute within the C function. I’ve been unable to figure out how to do this with the getAttrib() function; for instance, the main line of this function below will evaluate to true, indicating a null value.

SEXP test(SEXP x)
{
    isNull(getAttrib(x, mkChar("myname")));
}

Scanning the R extension writing manual has not helped me much, as all the examples of getAttrib() involve predefined symbols, such as getAttrib(x, R_DimSymbol). This section describes how to attach a custom attribute to a SEXP object you are creating in C, but not how to get at such a custom attribute that is associated with an object that is being passed into the C function.

  • 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-05-26T17:26:36+00:00Added an answer on May 26, 2026 at 5:26 pm

    You need to install the attribute to the symbol lookup table. There isn’t an example of using getAttrib in section 5.9.4 (Attributes) of Writing R Extensions, but there are several examples in xts.h.

    The code below should evaluate to FALSE.

    SEXP test(SEXP x)
    {
        isNull(getAttrib(x, install("myname")));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.