Try this:
lapply(list(c('ah', 'ihd'), 'ah', 'ihd'), function(x)subset(aDF, diagnosis
== x))
On Thu, Jan 20, 2011 at 6:53 AM, Den <[email protected]> wrote:
> Dear R people
> Could you please help.
>
> Basically, there are two variables in my data set. Each patient ('id')
> may have one or more diseases ('diagnosis'). It looks like
>
> id diagnosis
> 1 ah
> 2 ah
> 2 ihd
> 2 im
> 3 ah
> 3 stroke
> 4 ah
> 4 ihd
> 4 angina
> 5 ihd
> ..............
> Q: How to make three data sets:
> 1. Patients with ah and ihd
> 2. Patients with ah but no ihd
> 3. Patients with ihd but no ah?
>
> If you have any ideas could just guide what should I look for. Is a
> subset or aggregate, or loops, or something else??? I am a bit lost. (F1
> F1 F1 !!!:)
> Thank you
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.