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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:33:28+00:00 2026-05-24T19:33:28+00:00

I am new to R and trying to do some correlation analysis on multiple

  • 0

I am new to R and trying to do some correlation analysis on multiple sets of data. I am able to do the analysis, but I am trying to figure out how I can output the results of my data. I’d like to have output like the following:

 NAME,COR1,COR2
 ....,....,....
 ....,....,....

If I could write such a file to output, then I can post process it as needed. My processing script looks like this:

run_analysis <- function(logfile, name)
{
  preds <- read.table(logfile, header=T, sep=",")

  # do something with the data: create some_col, another_col, etc.

  result1 <- cor(some_col, another_col)
  result1 <- cor(some_col2, another_col2)

  # somehow output name,result1,result2 to a CSV file
 }

args <- commandArgs(trailingOnly = TRUE)
date <- args[1]
basepath <- args[2]
logbase <- paste(basepath, date, sep="/")
logfile_pattern <- paste( "*", date, "csv", sep=".")
logfiles <- list.files(path=logbase, pattern=logfile_pattern)

for (f in logfiles) {
  name = unlist(strsplit(f,"\\."))[1]
  logfile = paste(logbase, f, sep="/")
  run_analysis(logfile, name)
}

Is there an easy way to create a blank data frame and then add data to it, row by row?

  • 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-24T19:33:29+00:00Added an answer on May 24, 2026 at 7:33 pm

    Have you looked at the functions in R for writing data to files? For instance, write.csv. Perhaps something like this:

    rs <- data.frame(name = name, COR1 = result1, COR2 = result2)
    write.csv(rs,"path/to/file",append = TRUE,...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying some C++, but I'm too new to this and you can
I am trying out some globalization in an asp.net mvc2 application but can't get
I am relatively new to Java and while trying out some code came across
we at our company are trying out some new technologies so thought of redesigning
I've been trying to figure out how glTexImage2D works and an seeing some odd
Am new to RoR paperclip gem and i have been trying out some examples
I'm quite new to openGL and I have been trying out some sample codes
I'm new to C but trying some system calls. I'm writing program that iterates
I'm new to MVC. Trying out some sample code to list items from db.
I'm new to Cocos2d and am trying out some of the basic drawing functions.

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.