Make a subset with the same condition in different bases in the R

0

I want to apply the same condition of subset to different bases in R. I thought for would solve, but I did not succeed.

Follow the programming used:

for(i in c("mar16", "jun16", "set16", "dez16", "mar17")){
 postos[i]<-subset(postos[i],postos[i]$SEGMENTO=="Bancos")
}

Can you use for for this type of situation?

    
asked by anonymous 09.08.2017 / 16:29

1 answer

-1

You can use the functions lapply and split .

Ex: lapply(split(postos, postos$SEGMENTO), i).

    
11.08.2017 / 21:15