-2

First off I would like to say I am very new to R, about 2 weeks old. I am not sure the best way to phrase this but I have a table, consisting of 4 columns and 6 rows. I would like to pull all rows that match a word in a specific field.

Opened Created_by ticket closed
5/11   John Doe   773    TRUE
5/11   Jane Doe   774    FALSE
5/11   Jack Doe   775    TRUE
6/1    John Doe   805    TRUE
6/1    John Doe   806    FALSE
6/1    Jane Doe   807    TRUE

I want to see all the Tickets created by John Doe, so it would look something like this after I entered the correct code.

5/11 John Doe 773 TRUE
6/1  John Doe 805 TRUE
6/1  John Doe 806 FALSE
Metrics
  • 15,172
  • 7
  • 54
  • 83
MLTS
  • 9
  • 2
  • 2
    [Try something. Put forth some effort.](http://whathaveyoutried.com) –  Aug 25 '13 at 21:27
  • possible duplicate of [Remove Rows From Data Frame where a Row match a String](http://stackoverflow.com/questions/6650510/remove-rows-from-data-frame-where-a-row-match-a-string) – Ferdinand.kraft Aug 25 '13 at 23:00

3 Answers3

2

Assuming your data frame is named "dat":

dat[dat$Created_by == "John Doe",]
David
  • 9,284
  • 3
  • 41
  • 40
1
subset(x = dat, subset = Created_by == "John Doe")

See also this discussion

Community
  • 1
  • 1
Henrik
  • 65,555
  • 14
  • 143
  • 159
0

This may not be what you are looking for but if you want general approach that allows your to match one or more than one then you can use %in%. Assuming mydata if your dataframe:

myword<-c("John Doe", "Jane Doe")

mydata[mydata$Created_by %in% myword,]

Example using iris data:

myspecies<-c("setosa","versicolor")
mydata<-iris
mydata[mydata$Species %in% myspecies,]
Metrics
  • 15,172
  • 7
  • 54
  • 83