I\'m trying to figure out a simple way to do something like this with dplyr (data set = dat, variable = x):
day$x[dat$x<0]=NA
Should be
You can use the is.na<- function:
is.na<-
dat %>% mutate(x = "is.na<-"(x, x < 0))
Or you can use mathematical operators:
dat %>% mutate(x = NA ^ (x < 0) * x)