Reputation:
I have a set of dataset, but I would like to extract rows that contain specific keywords.
I tried using the codes below, and it works. But I just wondering if there is any better way in doing this.
test1 <- subset(data, grepl("love|hate", Content))
test2 <- subset(data, grepl("love|hate", Articles))
together <- unique(rbind(test1, test2))
I tried combining together, but failed to do so:
test1 <- subset(data, grepl("love|hate", Content, Articles))
Upvotes: 1
Views: 45
Reputation: 5779
Try this:
data[grepl("love|hate",data$Content) & grepl("love|hate",data$Articles),]
Upvotes: 1