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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:29:25+00:00 2026-05-20T21:29:25+00:00

I have a dataset with 20 variables v1 – v20. Now I’d like to

  • 0

I have a dataset with 20 variables v1 – v20. Now I’d like to use cor(…) to calculate the correlation between v2 and v10 until v15 and v3 and v10 until v15. What’s the best way to do this? Do I have to do this for each variable pair using

cor(v2, v10)
cor(v2, v11)
cor(v2, v12)
and so on?

Here is the actual dataset:

   > dput(dataset)
structure(list(Number = 1:15, Question.1.1 = c(3L, 4L, 5L, 5L, 
4L, 5L, 5L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L), Question.1.2 = c(1L, 
2L, 1L, 1L, 4L, 1L, 1L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 1L), Question.2.1 = c(5L, 
3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), Question.2.2 = c(2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), Question.3.1 = c(2L, 
NA, 4L, 5L, 4L, 3L, 5L, 3L, 5L, 5L, 5L, 5L, 4L, 4L, 4L), Question.3.2 = c(2L, 
NA, 1L, 1L, 2L, 2L, 1L, 4L, 3L, 1L, 1L, 1L, 2L, 2L, 1L), Question.4.1 = c(3L, 
2L, 5L, 2L, 5L, 5L, 5L, 3L, 5L, 5L, 5L, 5L, 4L, 5L, 2L), Question.4.2 = c(2L, 
2L, 1L, 2L, 2L, 1L, 2L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 4L), Question.5.1 = c(5L, 
3L, 5L, 3L, 4L, 4L, 5L, 3L, 5L, 5L, 5L, 5L, 5L, 4L, 4L), Question.5.2 = c(2L, 
2L, 1L, 1L, 3L, 2L, 1L, 3L, 4L, 1L, 1L, 1L, 1L, 1L, 1L), Question.6.1 = c(5L, 
2L, 2L, 2L, 3L, 2L, 3L, 1L, 3L, 3L, 5L, 4L, 3L, 3L, 1L), Question.6.2 = c(2L, 
3L, 2L, 1L, 2L, 3L, 3L, 3L, 3L, 2L, 1L, 1L, 2L, 2L, 1L), Question.7.1 = c(5L, 
2L, 5L, 5L, 5L, 3L, 5L, 5L, 2L, 4L, 5L, 5L, 5L, 4L, 5L), Question.7.2 = c(1L, 
4L, 1L, 1L, 2L, 2L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L), Question.8.1 = c(4L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), Question.8.2 = c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), Question.9.1 = c(5L, 
3L, 5L, 4L, 4L, 5L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 4L, 3L), Question.9.2 = c(1L, 
1L, 1L, 2L, 2L, 1L, 2L, 1L, 4L, 2L, 1L, 2L, 2L,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L, 2L, 1L, 2L), GQ.9 = c(3L, 
5L, 2L, 3L, 4L, 4L, 5L, 3L, 4L, 4L, 3L, 3L, 4L, 2L, 2L), GQ.10 = c(3L, 
4L, 1L, 2L, 3L, 4L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 5L, 2L), Feature.1 = c(4L, 
4L, 2L, 3L, 4L, 4L, 5L, 5L, 4L, 5L, 5L, 4L, 5L, 3L, 4L), Feature.2 = c(4L, 
4L, 2L, 1L, 5L, 4L, 5L, 5L, 5L, 4L, 4L, 3L, 5L, 3L, 2L), Feature.3 = c(3L, 
2L, 1L, 2L, 5L, 5L, 2L, 4L, 2L, 4L, 4L, 5L, 2L, 4L, 2L), Feature.4 = c(3L, 
3L, 3L, 4L, 3L, 4L, 5L, 5L, 4L, 4L, 4L, 3L, 4L, 3L, 3L), Feature.5 = c(2L, 
2L, 3L, 3L, 4L, 3L, 4L, 4L, 2L, 4L, 3L, 4L, 5L, 3L, 1L), Feature.6 = c(5L, 
5L, 1L, 1L, 5L, 5L, 5L, 4L, 4L, 5L, 5L, 5L, 5L, 4L, 4L), Feature.7 = c(5L, 
3L, 2L, 5L, 4L, 5L, 3L, 5L, 4L, 5L, 5L, 5L, 5L, 4L, 4L)), .Names = c("Number", 
"Question.1.1", "Question.1.2", "Question.2.1", "Question.2.2", 
"Question.3.1", "Question.3.2", "Question.4.1", "Question.4.2", 
"Question.5.1", "Question.5.2", "Question.6.1", "Question.6.2", 
"Question.7.1", "Question.7.2", "Question.8.1", "Question.8.2", 
"Question.9.1", "Question.9.2", "AQ.1", "AQ.2", "Task.1", "Task.2", 
"Task.3", "Task.4", "Task.5", "GQ.1", "GQ.2", "GQ.3", "GQ.4", 
"GQ.5", "GQ.6", "GQ.7", "GQ.8", "GQ.9", "GQ.10", "Feature.1", 
"Feature.2", "Feature.3", "Feature.4", "Feature.5", "Feature.6", 
"Feature.7"), class = "data.frame", row.names = c(NA, -15L))
  • 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-20T21:29:26+00:00Added an answer on May 20, 2026 at 9:29 pm

    I may have misunderstood the problem… but why don’t you just to run cor on the data frame?

    For instance:

    data <- data.frame(q1=sample(1:5, 15, rep=1), 
              q2=sample(1:5, 15, rep=1), 
              q3=sample(1:5, 15, rep=1), 
              q4=sample(1:5, 15, rep=1), 
              q5=sample(1:5, 15, rep=1), 
              q6=sample(1:5, 15, rep=1), 
              q7=sample(1:5, 15, rep=1), 
              q8=sample(1:5, 15, rep=1), 
              q9=sample(1:5, 15, rep=1), 
              q10=sample(1:5, 15, rep=1))
    
    print(cor(data))
    

    You can even

    image(cor(data), x=1:10, y=1:10, zlim=c(-1,1))
    

    If you just need certain values of correlations just put the result of corr in a variable and pull out the results you need.

    For instance, we want the correlation of column 2 with columns 5 to 10 we will:

    corrs <- cor(data)
    print(corrs[2, 5:10]) # or corrs[5:10, 2], the correlation matrix is symmetric
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataset of environmental variables I would like to use for a
I have a dataset something like this: col_a col_b col_c 1 abc_boy 1 2
I am using a dataset with variables that have very similar names. I have
I have a dataset with more than 200 features and I would like to
I have loaded a dataset, D, into R and I would like to perform
I have some code where I am trying to use variables in a tabpage.
Let's say I have a Stata dataset that has two variables: type and price
I have a dataset with three variables. One continous independent variable, one continous dependent
I have a dataset with an x variable and two y1 and y2 variables
I have a dataset with the following variables: condition: 1,2,3 type: friend, foe Proportion_Choosing_Message:

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.