I would like to remove the rownames ONLY of the rows which contain "Apple_"
df <- data.frame('fruit'=c("Apple_1", "Apple_2", "Apple_3", "Pear_1", "Pear_2", "Pear_3"),
'color'=c("Red", "Red", "Green","Green","Green","Green"))
df<- column_to_rownames(df, var="fruit")
None of these work because I belive there aren't any rows called just "Apple"
row.names.remove <- c("Apple")
df[!(row.names(df) %in% row.names.remove), ]
df2<- length(which(grepl("Apple", rownames(df))))
df3<- df[row.names(df) != "Apple", , drop = FALSE]