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

The Archive Base Latest Questions

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

when calling a function in R, how can I retrieve the result values. For

  • 0

when calling a function in R, how can I retrieve the result values. For example, I used ‘roc’ function and I need to extract AUC value and CI (0.6693 and 0.6196-0.7191 respectively in the following example).

> roc(tmpData[,lenCnames], fitted(model), ci=TRUE)

Call:
roc.default(response = tmpData[, lenCnames], predictor = fitted(model),     ci = TRUE)

Data: fitted(model) in 127 controls (tmpData[, lenCnames] 0) < 3248 cases (tmpData[, lenCnames] 1).
Area under the curve: 0.6693
95% CI: 0.6196-0.7191 (DeLong)

I can use the following to fetch these values with associated texts.

> z$auc
Area under the curve: 0.6693
> z$ci
95% CI: 0.6196-0.7191 (DeLong)

Is there a way to get only the values and not the text.

I do now how to get these using ‘regular expression’ or ‘strsplit’ function, but I suspect there should be some other way to directly access these values.

  • 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-17T15:12:30+00:00Added an answer on June 17, 2026 at 3:12 pm

    It’s helpful to use reproducible examples when asking a question. Also best to refer to the library you’re asking about (“pROC”), since it is not loaded with base R. pROC has functions that extract auc and ci.auc objects from the roc object.

    >library("pROC")
    >data(aSAH)
    # Basic example
    >z <- roc(aSAH$outcome, aSAH$s100b,
        levels=c("Good", "Poor"))
    
    # Examining the class of 'auc' output shows us that it is also of class 'numeric'
    > class(auc(z))
    [1] "auc"     "numeric"
    # calling 'as.numeric' will extract the value
    > as.numeric(auc(z))
    [1] 0.7313686
    
    # calling 'as.numeric' on the 'ci.auc' object extracts three values.
    as.numeric(ci(z))
    [1] 0.6301182 0.7313686 0.8326189
    
    # The ones we want are 1 and 3
    > as.numeric(ci(z))[c(1,3)]
    [1] 0.6301182 0.8326189
    

    Using the functions str, class, and attributes will often help you figure out how to get what you want out of an object.

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

Sidebar

Related Questions

I'm trying to return a value from (transport) to the calling function, but can't
I'm having trouble with the MyClass::function(); style of calling methods and can't figure out
Does anyone know how to watch a variable in calling function. For example: C#:
I'm calling a function from an input radio button and have this: onClick=\changeBilling('.$results['id'].', this.value)\
Suppose you are calling a function, where there's clearly a need to break down
I have this function that I'm calling to retrieve some JSON data and use
i am going to call a function which will retrieve some data value from
Possible Duplicate: calling ASP function from javascript okay running this code : <script type=text/javascript>
I am calling a function funcB from funcA . funcB uses several printf statements
I'm calling a function and adding a listener for when the function returns some

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.