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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:50:14+00:00 2026-05-27T17:50:14+00:00

The below dataset and code creates a new dataset with the results from cor.test

  • 0

The below dataset and code creates a new dataset with the results from cor.test being performed on each individual (‘Individual_ID’) from my original dataset. How do I convert each variable from the cor.test results to a numeric data type, as it is passed into the new dataframe? For example, ‘estimate’, ‘p.value’, and ‘conf.int’ should be numeric not character. Second, I would like variable ‘conf.int’ to be two variables, ‘lowlim’ and ‘uplim’.

## Create sample dataset
WW_Wing_SI <-
structure(list(Individual_ID = c("WW_08A_02", "WW_08A_02", "WW_08A_02",
"WW_08A_02", "WW_08A_02", "WW_08A_02", "WW_08A_02", "WW_08A_02",
"WW_08A_02", "WW_08A_03", "WW_08A_03", "WW_08A_03", "WW_08A_03",
"WW_08A_03", "WW_08A_03", "WW_08A_03", "WW_08A_03", "WW_08A_03"
), FeatherPosition = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4,
5, 6, 7, 8, 9), Delta13C = c(-18.67, -19.16, -20.38, -20.96,
-21.61, -21.65, -21.31, -20.8, -21.28, -20.06, -20.3, -21.21,
-22.9, -22.87, -21.13, -20.68, -20.58, -20.69)), .Names = c("Individual_ID",
"FeatherPosition", "Delta13C"), row.names = c(NA, 18L), class = "data.frame")

# split data frame according the the individual IDs
individual.list <- split(WW_Wing_SI, WW_Wing_SI$Individual_ID)

# apply cor.test() with extract to each element of the list
test <- as.data.frame(t(sapply(individual.list, function(temp)
                        cor.test(temp$Delta13C, temp$FeatherPosition,
                        method="pearson")[c("estimate", "p.value", "conf.int")])))
  • 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-27T17:50:14+00:00Added an answer on May 27, 2026 at 5:50 pm

    This is how I’d do it. If you do everything “right”, the output is already in numeric so no coercion is necessary (if not, you would use as.numeric(object$variable)). When I create the inter variable, I insert the desired components so that I can construct lower/upper CI variables. Notice, that test is now a “proper” data.frame that can be easier to work with (you can easily extract any item you want).

    # split data frame according the the individual IDs
    individual.list <- split(WW_Wing_SI, WW_Wing_SI$Individual_ID)
    
    # apply cor.test() with extract to each element of the list
    inter <- sapply(individual.list, function(temp) {
                a <- cor.test(temp$Delta13C, temp$FeatherPosition,
                        method="pearson")[c("estimate", "p.value", "conf.int")]
                out <- data.frame(cor = a$estimate, p.value = a$p.value, lowerCI = a$conf.int[1], upperCI = a$conf.int[2])
            }, simplify = FALSE)
    test <- do.call("rbind", inter)
    test
    
                      cor    p.value    lowerCI    upperCI
    WW_08A_02 -0.76706752 0.01585509 -0.9481677 -0.2098478
    WW_08A_03 -0.02320767 0.95274294 -0.6768966  0.6509469
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below is from SAMATE Reference Dataset . I used it to test
I am adding data to a dataset using the below code cmdExcel.CommandText = SELECT
So lets say I have some code like below to pull data from another
I using a dataset to read an xml file as shown below DataSet ds
Below is the code of a simple html with a table layout. In FF
Below are lines from the c++ programming language template<class T > T sqrt(T );
Below is a code snippet for passing a table as a parameter to a
Can you have a look at the code below and tell me how I
This following code gives me the error below . I think I need InvokeRequired
Consider the code below (which has been simplified). I have a service class that

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.