0

I'm new to programming in R, and programming in general. I have a dataframe 'd' with columns Rating, Type, Source, Prob and some 200 rows. Can anyone tell me how I would best go about creating a new dataframe 'd_A' from an existing dataframe 'd' selecting (creating new dataframe from) only rows from 'd' where the value in the first column 'Rating' (d$Rating) is EITHER 'A-' or 'A+'?

This is smaller version of 'd': enter image description here

Many thanks in advance :)

ProgrNewb
  • 21
  • 1
  • 1
  • 1
    http://stackoverflow.com/questions/1686569/filtering-a-data-frame – din Apr 11 '17 at 13:20
  • Welcome on SO! Please use `dput()`to show your data (or the definition of the dataframe `... <- data.frame(...)`). Please read [ask] and [mcve] ... then edit your question: http://stackoverflow.com/posts/43347110/edit – jogo Apr 12 '17 at 08:03

1 Answers1

0

Pretty easy:

d_A <- d[d$Rating=="A-"|d$Rating=="A+",]

There ya go, a dataframe called d_A where you only got rows from d which presented a value of Rating of either A+ or A-.

Gius Dep
  • 70
  • 8