Let\'s say if I have the following data
x <- rnorm(100)
I want to create another column where where if x is equal to or gre
x
We can create the logical condition and wrap with +
+
xNew <- +(x >=0.2)
If we need a data.frame,
data.frame
dat <- data.frame(x, xNew)
Or use ifelse
ifelse
xNew <- ifelse(x >= 0.2, 1, 0)