Skip to content
Prev 247827 / 398503 Next

subsets

Hi!

I think you should read the intro to R, as well as ?"[" and ?subset. It 
should help you to understand.

Let's say your data is in a data.frame called df:
# 1. ah and ihd
df_ah_ihd <- df[df$diagnosis=="ah" | df$diagnosis=="ihd", ]  ## the "|" 
is the boolean OR (you want one OR the other). Note the last comma

#2. ah
df_ah <- df[df$diagnosis=="ah", ]

#3. ihd
df_ihd <- df[df$diagnosis=="ihd", ]

You could do the same using subset() if you feel better with this function.

HTH,
Ivan

Le 1/20/2011 09:53, Den a ?crit :