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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:42:10+00:00 2026-06-14T22:42:10+00:00

I have a dataframe with 20 classrooms [1 to 20] indexes and 20 different

  • 0

I have a dataframe with 20 classrooms [1 to 20] indexes and 20 different number of students in each class, how to obtain all sub-samples of size n = 8 and store them because i want to use them later for calculations. I used combn() but that takes only one vector, can i use it with a dataframe and how? (sorry but i’m new in R),
dataframe below:

   classrooms students
1           1       29
2           2       30
3           3       35
4           4       28
5           5       32
6           6       20
7           7       25
8           8       22
9           9       32
10         10       26
11         11       27
12         12       34
13         13       27
14         14       28
15         15       33
16         16       21
17         17       36
18         18       24
19         19       19
20         20       32
  • 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-14T22:42:12+00:00Added an answer on June 14, 2026 at 10:42 pm

    It is as simple as passing a function to combn. simplify = FALSE means that a list will be returned.

    Assuming you want all possible combinations of 8 classrooms from the dataset classrooms

     combinations <- combn(nrow(classrooms), 8, function(x,data) data[x,], 
                      simplify = FALSE, data =classrooms )
    
     head(combinations, n = 2)
    
    [[1]]
      classrooms students
    1          1       29
    2          2       30
    3          3       35
    4          4       28
    5          5       32
    6          6       20
    7          7       25
    8          8       22
    
    [[2]]
      classrooms students
    1          1       29
    2          2       30
    3          3       35
    4          4       28
    5          5       32
    6          6       20
    7          7       25
    9          9       32
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataframe df.all and I'm plotting it in a bar plot with
I have a dataframe made up of 6 columns. Columns 1 to 5 each
I have a dataframe of 9 columns consisting of an inventory of factors. Each
I have a dataframe where a few indexes are string values. How can I
I have a dataframe as shown below listing the number of injuries by vehicle
I have a dataframe m and I want to remove all the rows where
I have a dataframe, and I wish to round all of the numbers (ready
I have a dataframe with distances df<-data.frame(site.x=c(A,A,A,B,B,C), site.y=c(B,C,D,C,D,D),Distance=c(67,57,64,60,67,60)) I need to convert this to
I have a dataframe x with this values: x1 x2 x3 1 NA 4
I have a dataframe with some numeric columns. Some row has a 0 value

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.