Danilo, how are you?
I suggest doing the following:
Creating a data frame to serve as an example:
a <- c(1,2,3,4,5,6,7,8,9,10)
b <- c(10,9,8,7,6,5,4,3,2,1)
df <- data.frame(a,b)
> print(df)
a b
1 1 10
2 2 9
3 3 8
4 4 7
5 5 6
6 6 5
7 7 4
8 8 3
9 9 2
10 10 1
One way to get only values greater than 6 from column b is as follows:
df$b[df$b > 6]
So, just take the same idea and directly assign the desired value, which in your case is NA:
df$b[df$b > 6] <- NA
> print(df)
a b
1 1 NA
2 2 NA
3 3 NA
4 4 NA
5 5 6
6 6 5
7 7 4
8 8 3
9 9 2
10 10 1