Re: [R] Basic question - more efficient method than loop?

From: Allan Engelhardt <allane_at_cybaea.com>
Date: Mon, 28 Jun 2010 17:18:25 +0100

On 28/06/10 16:46, GL wrote:
> I'm guessing there's a more efficient way to do the following using the index
> features of R. Appreciate any thoughts....
>
> for (i in 1:nrow(dbs1)){
> if(dbs1$Payor[i] %in% Payor.Group.Medicaid) dbs1$Payor.Group[i] =
> "Medicaid"

>

Try something like

dbs1$Payor.Group[dbs1$Payor %in% Payor.Group.Medicaid]<- "Medicaid" etc.

to get started.

Hope this helps.

Allan

> [...]
>



R-help_at_r-project.org 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. Received on Mon 28 Jun 2010 - 16:21:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 Jun 2010 - 16:40:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive