0

Data frame

Hello, I am very new to R and was hoping someone can help me to get started on this project! I have attached a picture of my data frame above for clarity

so, my data frame has 20 columns and 20000 rows. I would like to group my data frame into a new or the old data frame by column "Name" where similar numbers to be grouped together and where The "model" column has more than one "D", i want the entire group to be deleted from the data frame. there are other columns in the data frame that i will need to use later but first step, i need to delete the grouping that has more than one D thank you in advance.

Toney Honar
  • 57
  • 2
  • 3
  • 1
    Please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – mpalanco Jul 31 '18 at 13:57

1 Answers1

0

Data:

data<-cbind.data.frame(
      name=sapply(1:200,FUN=function(x) x=paste0(sample(x=c("D","E","F","H","N"),size=5,replace = T),collapse = "")),
      value=rnorm(200)) 

Now, find out which rows in name column have more than two d (upper or lower case) "[dD]{2,}"

index<-grepl("[dD]{2,}",data$name)

And, at last subset your data:

data[!index,]
     name        value
1   DNNFD  0.710399226
2   FDFFN -1.140585633
3   FHDEF  0.319493935
4   HNEFE -1.161941990
5   HFEFE  0.087838201
6   EHDEF  0.983140773
Iman
  • 2,224
  • 15
  • 35