I have the following dataset

```seqno   rectyp  ps04
1       1
1       1
1       89
1       89
2       1       0
2       1       1
2       1
2       90
2       89
3       1
3       1
3       1
3       90
3       90
3       89      1
3       89      5
3       89      6
3       89  ```

I would like to do is look for values ps04==1 and rectype==1 for a certain seqno value. Once found, it will fill out the whole rows of that seqno with value 1. Expected output would be:

```seqno   rectyp  ps04
1       1
1       1
1       89
1       89
2       1       1
2       1       1
2       1       1
2       90      1
2       89      1
3       1
3       1
3       1
3       90
3       90
3       89      1
3       89      5
3       89      6
3       89  ```
Nov 13, 2018 564 views

## 1 answer to this question.

First see what rows meet t\$ps04==1 & t\$rectyp==1. Get the seqno for those and then make i equal TRUE for all the rows that meet the condition.

```> i <- t\$seqno %in% t\$seqno[t\$ps04==1 & t\$rectyp==1]
> i
[1] FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> t\$ps04[i] <- 1 # set values to 1
> t
seqno rectyp ps04
1      1      1   NA
2      1      1   NA
3      1     89   NA
4      1     89   NA
5      2      1    1
6      2      1    1
7      2      1    1
8      2     90    1
9      2     89    1
10     3      1   NA
11     3      1   NA
12     3      1   NA
13     3     90   NA
14     3     90   NA
15     3     89    1
16     3     89    5
17     3     89    6
18     3     89   NA```
answered Nov 13, 2018 by
• 10,840 points

+1 vote

## Finding number of missing values and removing those missing values from a data-frame

To find number of missing values for ...READ MORE

## R Error: Recommender method UCBF not implemented for data type realRatingMatrix

Kalyan, Try changing method from UBCF to POPULAR. train ...READ MORE

## Building Random Forest on a data-set comprising of missing(NA) values

You have two options, either impute the ...READ MORE

## In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

## How to remove certain character from a vector

We can use sub to remove the * by specifying fixed = ...READ MORE

+1 vote

## How to standardize rows when cleaning data?

The goal of this step is to ...READ MORE

+1 vote

## How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

## Clean a set of data using R

Try this: NCM <- c(5,1,3,2,4) Mbrand <- c(1,5,3,4,2) fac<-factor(Mbrand, levels ...READ MORE