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

The Archive Base Latest Questions

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

I want to calculate correlation matrix P which each P[i,j] is correlation coefficient of

  • 0

I want to calculate correlation matrix P which each P[i,j] is correlation coefficient of row i and col j in matrix Data. for example

  Data <- matrix(rnorm(500),50,10)
  P <- matrix(0,50,50)
  for (i in 1:50) 
     for(j in 1:50)
        P[i,j] <- cor(Data[i,],Data[j,])

But how can I use apply or something like this command to calculate such correlations.

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

    You can just use cor() on a data frame or matrix to obtain a correlation matrix of correlations between all pairs of columns:

    cor(t(Data))
    

    From your question and code it is not clear if you want correlations for all pairs of rows or correlations between rows and columns, but since the matrix is not square I assumed the first.

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

Sidebar

Related Questions

I have a matrix with two columns. I want to calculate running 60-day correlation
I want to calculate number of used columns for each row in excel 2007
I want to calculate Centered Moving average of a set of Data . Example
I want to calculate the average of a set of circular data. For example,
I want to calculate phase correlation of function in OpenCV. I've found http://nashruddin.com/phase-correlation-function-in-opencv.html but
I want to calculate the difference between two times, one of which is the
May you correct my loop function. I want to calculate correlation of colomns of
I want to calculate the time span between 2 times which I saved in
I want to calculate number of days from a date. For example, we have
I have a dataframe and would like to calculate the correlation (with Spearman, data

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.