I have a difficulty when working with a R script. If I run this line in the command line it works perfectly

```
dbnasc$ano[which(dbnasc$ano>=1605 & dbnasc$ano<1610)]=1605

```

But if define a function with the same code in it doesn't work

```
#Função recode
xclass1=function(ini,fim,per){
t=seq(ini,fim,by=per)
z=length(t)
i=1
while(i<z){
  a0=t[[i]]
  a1=t[[i+1]]
  dbnasc$ano[which(dbnasc$ano>=a0 & dbnasc$ano<a1)] = a0
  i=i+1
  } 
}

```