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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:44:44+00:00 2026-06-11T13:44:44+00:00

This has got to be a simple answer. I want to subset my data

  • 0

This has got to be a simple answer. I want to subset my data for testing purposes. I have a data frame where I want to keep all columns of information, just simply reduce the number of observations PER individual. So, I have a unique Identifier and about 50 individuals. I want to select only 2 individuals AND and I want to select only 500 data points from those 2.

My data frame is called wloc08. There are 50 unique IDs. I am only taking 2 of those individuals but of those 2, I’d like only 500 data points from each.

subwloc08=subset(wloc08, subset = ID %in% c("F07001","F07005"))

somewhere in this statement can I use [?

 reduced= subwloc08$ID[1:500,]

Doesn’t work.

  • 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-11T13:44:45+00:00Added an answer on June 11, 2026 at 1:44 pm

    You could use lapply:

    do.call("rbind",
            lapply(c("F07001", "F07005"),
                   function(x) wloc08[which(wloc08$ID == x)[1:500], ]))
    

    Your command reduced = subwloc08$ID[1:500,] didn’t work since subwloc08$ID is a vector. However, reduced = subwloc08$ID[1:500] would have worked but would have returned the first 500 values of subwloc08$ID (not the whole rows of subwloc08).

    If you want to run this command for the first 30 subjects, you could use unique(wloc08$ID)[1:30] instead of c("F07001", "F07005"):

    do.call("rbind",
            lapply(unique(wloc08$ID)[1:30],
                   function(x) wloc08[which(wloc08$ID == x)[1:500], ]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The answer to this has got to be simple, but I sure don't see
I'm sure this has got a simple answer, but it's stumping me :( I'm
I want to achieve the functionality that this editor has got with its preview
Given that django-nonrel has got JOINs working, does this mean we have M2M fields
I've got a question that probably has a pretty simple answer, but I didn't
This problem has got me stumped for a few days now. I have a
This has got to be extremely simple but I'm banging my head against the
I've got some simple survey data that I'd love to have a hand with.
It's possible that this question either has a simple answer that's a standard practice,
I've been working on some MySQL Joins but this one has got me a

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.