I have an R data.frame object
long <- c(100.25,100.75,100.75,100.75,100.75,100.75,101.25,99.25,99.25,100.25)
vars <- c(1750.8, 1789.7, 1788.1, 1782.8, 1867.3, 1771.3, 1789.9, 1820.6, 1789.1, 1868.9)
varp <- c(1470.714, 1279.862, 1306.740, 1190.296, 1762.874, 1464.975, 1619.855, 1744.476,
1879.743, 2052.337)
df1 <- data.frame(varp,vars,long)
I would like to replace all values in vars by NA which satisfy folowing condition
(df$long <= 100.75 & df$long >= 100.25)
I have tried
ind<- which(df1$long <= 100.75 & df1$long >= 100.25)
i get
ind
[1] 1 2 3 4 5 6 10 #
which are the TRUE values of above condition
and if I use
df1$vars[-ind]
[1] 1789.9 1820.6 1789.1 #
I get FLASE value of above condition
could somebody please tell me how I can replace these FALSE Index in vars by NA in data.frame?