I have a problem with the cleaning of a database. What I want is to keep only the rows where in column B the word starts with "b". My actual code is:
library(dplyr)
db_class <- data.frame(A=c(2,3,3,2,1),B=c("ax","ac","bs","br","cv"),C=c(14,15,17,12,14))
row_numbers <- c(db_class %>% rowwise() %>% mutate(Pos = which((db_class$B) == starts_with("b")[1]))
db_class_clean <- db_class[row_numbers,]
I tried to write this code but it doesn't work..