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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:33:54+00:00 2026-06-13T05:33:54+00:00

I have a data.frame, d: d<-data.frame(id=c(1,1,1,1,2,2,3,3,3,3), var=c(no, no, no, yes, no, yes, no, yes,

  • 0

I have a data.frame, d:

d<-data.frame(id=c(1,1,1,1,2,2,3,3,3,3), var=c("no", "no", "no", "yes", "no", "yes", "no", "yes", "yes", "yes"))

I’d like to return all “no” rows for each ID leading up to a “yes” and including the first “yes”.

desired result:

id var
1  no
1  no
1  no
1 yes
2  no
2 yes
3  no
3 yes
  • 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-13T05:33:55+00:00Added an answer on June 13, 2026 at 5:33 am

    As @joran indicates, it’s polite to include what you’ve tried. It also increases the likelihood your question will get votes. This question is basic enough that even a rudimentary understanding of R could arrive at something.

    In any case, this will do what you want:

    d[! duplicated(d) | d$var == 'no', ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame like below (20,000 rows by 49 cols). Each row
I have the following data test<-data.frame(group=1:10, var.a=rnorm(n=10,mean=500,sd=20), var.b=runif(10)) I would like a barplot with
I have two data frames. First one looks like dat <- data.frame(matrix(nrow=2,ncol=3)) names(dat) <-
I have a data frame that looks like this: site date var dil 1
I have two data frames like this: df.1 <- data.frame( var.1 = sample(1:10), code
I have a data frame that is some 35,000 rows, by 7 columns. it
I have a data.frame of a time series of data, I would like to
I have a similar data frame as follows: mapDF <- structure(list(var = c(11L, 3L,
Suppose I have a date.frame like: df <- data.frame(a=1:5, b=sample(1:5, 5, replace=TRUE), c=5:1) df
I have a data frame 1488 obs. and 400 var. I am trying to

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.