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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:06:13+00:00 2026-06-15T17:06:13+00:00

I have a list of 27 data frames with different numbers of rows in

  • 0

I have a list of 27 data frames with different numbers of rows in each frame but the same number of columns (22). I need the min, max, and median of each column put into a vector for each frame, the result should look something like this:

frame1 = (c1min, c1max, c1median, c2min, c2max, c2median … c22min, c22max, c22median)

frame2 = (c1min, c1max, c1median, c2min, c2max, c2median … c22min, c22max, c22median)

…

frame27 = (c1min, c1max, c1median, c2min, c2max, c2median … c22min, c22max, c22median)

I’ve generated the min of each column doing this:

> all_min = lapply(all_list, function(x){apply(x,2,min)})

Where ‘all_list’ is my list and ‘all_min’ is the vector for all the column mins in the list. I’m unsure as to how to get an numbered list of vectors (like in the example above), and how to get them properly formatted. Any ideas?

EDIT: Here’s an example of one of the frames:

          lx        ly        lz   ...
1  -0.039256 -0.078644 -0.032388 
2  -0.036041 -0.074536 -0.033906 
3  -0.033898 -0.071544 -0.033906
  • 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-15T17:06:14+00:00Added an answer on June 15, 2026 at 5:06 pm

    Reproducible data FTW.

    Anyhow, here’s a guess:

    lapply( all_list, function(dat) {
       sapply( c(min,max,median), function(fn) apply(dat,2,fn) )
    }) 
    

    Hard to test with no sample data though.

    This works by passing the functions as arguments to sapply. One of many ways in which “everything is an object” to R.

    lapply takes each element of all_list (in this case, a data.frame) and passes it as the first argument to the function it’s given. That function’s first argument is dat, so that’s what the data.frame will be called each time that function is run (e.g. for each data.frame contained in all_list).

    Then sapply works like lapply but does some cute arranging if it can. So it takes a vector of functions c(min,max,median) and assigns those to the first argument of the function in turn. That function’s first argument is fn, so that’s what each function will be called every time it is run. Cool.

    So now we have, for a single data.frame in all_list called dat and a single function called fn, a simple function that does what you’d originally set out–apply’s that summary function to each column of the data.frame.

    The final step is that sapply works its magic to return a matrix with the output in a tidy form. Then lapply includes that matrix as a element of the list which it will ultimately give back to you.

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

Sidebar

Related Questions

I have a huge list with data.frames (same number of columns, different number of
I have a list L of data frames with two columns each...a key, and
I have a list of different data types (factors, data.frames, and vectors, all the
Possible Duplicate: write.csv() a list of unequally sized data.frames I have a data frame
I have a list, listDFs , where each element is a data frame. Each
I have a list within a data frame (in this example, df$candpct ), and
I have a list of data that is a schedule. Each item has a
I have a list of core data objects each has a longitude and latitude
I have a list of comprising of sub-lists with different numbers of entries, as
I have a data.frame like this: (t=structure(list(count = c(NA, 2, NA, NA, NA, 8,

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.