# Analizamos las filas de dat1

for(i in 1:nrow(dat1)) {

# Si la nota del alumno es mayor o igual a 5, cambiamos el valor de 'aprobado' a 1

if(dat1\$notas[i] >= 5){
}
}

# Mostramos las primeras filas de dat1 para comprobar el resultado

I think we need to see some sample data.
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between
```

```

Here is an example of the code working. Does this code work for you?

``````dat1 <- data.frame(notas = c(8,6,9,10,3,7,4))
#Analizamos las filas de dat1

for(i in 1:nrow(dat1)) {
#Si la nota del alumno es mayor o igual a 5, cambiamos el valor de 'aprobado' a 1

if(dat1\$notas[i] >= 5){
}
}
#Mostramos las primeras filas de dat1 para comprobar el resultado

#> 1     8        1
#> 2     6        1
#> 3     9        1
#> 4    10        1
#> 5     3        0
#> 6     7        1
``````

Created on 2023-11-29 with reprex v2.0.2

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.