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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:01:54+00:00 2026-06-11T16:01:54+00:00

I have two dataframes and I would like to do independent 2-group t-tests on

  • 0

I have two dataframes and I would like to do independent 2-group t-tests on the rows (i.e. t.test(y1, y2) where y1 is a row in dataframe1 and y2 is matching row in dataframe2)

whats best way of accomplishing this?

EDIT:
I just found the format: dataframe1[i,] dataframe2[i,]. This will work in a loop. Is that the best solution?

  • 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-11T16:01:55+00:00Added an answer on June 11, 2026 at 4:01 pm

    The approach you outlined is reasonable, just make sure to preallocate your storage vector. I’d double check that you really want to compare the rows instead of the columns. Most datasets I work with have each row as a unit of observation and the columns represent separate responses/columns of interest Regardless, it’s your data – so if that’s what you need to do, here’s an approach:

    #Fake data
    df1 <- data.frame(matrix(runif(100),10))
    df2 <- data.frame(matrix(runif(100),10))
    
    
    #Preallocate results
    testresults <- vector("list", nrow(df1))
    #For loop
    for (j in seq(nrow(df1))){
      testresults[[j]] <- t.test(df1[j,], df2[j,])
    }
    

    You now have a list that is as long as you have rows in df1. I would then recommend using lapply and sapply to easily extract things out of the list object.

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

Sidebar

Related Questions

I have two dataframes; one is 48 rows long and looks like this: name
I have two dataframes, much like these: data = data.frame(data=cbind(1:12,rep(c(1,2),6),rep(c(1,2,3),4))) colnames(data)=c('v','h','c') lookup = data.frame(data=cbind(c(rep(1,3),rep(2,3)),rep(c(1,2,3),2),21:26))
I have two dataframes with the same number of columns. I'm writing a function
Suppose we have the contents of tables x and y in two dataframes in
I have two data.frames. For examples sake let's say they look like this: df1
Is it possible to row bind two data frames that don't have the same
I've got two dataframes that look like this: ==fileA LmjF.01 257506 257508 1 LmjF.01
I have the following matching problem: I have two data.frames, one with an observation
I have a dataframe that I would like to plot in a similar way
Here are my two data frames, both have the same amount of rows which

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.