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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:15:07+00:00 2026-06-18T02:15:07+00:00

I have the example data frame test.df<-data.frame(classifier=runif(n=1000), x1=rnorm(1000), x2=rnorm(1000), x3=rnorm(1000)) with x1 , x2

  • 0

I have the example data frame

test.df<-data.frame(classifier=runif(n=1000), x1=rnorm(1000), x2=rnorm(1000), x3=rnorm(1000))

with x1,x2,…,x10000

I would like to use the apply function to perform a large amount of tests (lets say t.test) and collect the results in a vector(lets say t.test()$p.value ). The test on a single column would be t.test(test.df$x1[ test.df$classifier<0.4 ], test.df$x1[ test.df$classifier>0.6 ])$p.value

I would like to perform this on all with x1,x2,…,x10000. I though I would use the apply function with MARGIN=2 but I cannot get the apply function to split every column vector according to the classifier.

(The example provided above has absolutely no statistical meaning. Don’t go viral)

Any help?

  • 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-18T02:15:08+00:00Added an answer on June 18, 2026 at 2:15 am

    Is this what you want ?

    df<-data.frame(classifier=runif(n=1000), x1=rnorm(1000), x2=rnorm(1000), x3=rnorm(1000))
    sapply(df[,-1], function(v) {
      t.test(v[df$classifier<0.4], v[df$classifier>0.6])$p.value
    })
    

    Which gives :

           x1        x2        x3 
    0.5028683 0.1238735 0.2021623 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many data.frames, for example: df1 = data.frame(names=c('a','b','c','c','d'),data1=c(1,2,3,4,5)) df2 = data.frame(names=c('a','e','e','c','c','d'),data2=c(1,2,3,4,5,6)) df3 =
I have a list within a data frame (in this example, df$candpct ), and
I have a data.frame in R which has been constructed off the Example 1-3
I have 2 dataframes in R for example df and dfrefseq. df<-data.frame( chr =
I have the following data frame: Test <- data.frame(Species = c(A,B,C,D), WB1=c(0.1,1.1,0.9,1.2), WB2=c(1, 0.8,
I have a data.frame in R, like this: fruits X1 X2 X3 aa kiwi
I have seen example of data driven frame work in Selenium WebDriver using java.
I have a large data frame with the following fields (example data). #dput(data) gives...
I have a 3 column data frame which looks a little like this: id
I have following structure with example data: id season_id title 1 1 Intro 2

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.