【方法】 df.x[dfx$x == 1, ]$new <- "x"
#サンプルデータ作成
v.x1 <- c(1,2,3,4,5,6,7,8,9,10)
v.x2 <- c("a","a","b","b","b","c","c","c","c","c")
v.x3 <- c(1000,900,800,700,600,500,400,300,200,100)
df.x <- data.frame(id = v.x1, item = v.x2, price =v.x3)
> df.x id item price 1 1 a 1000 2 2 a 900 3 3 b 800 4 4 b 700 5 5 b 600 6 6 c 500 7 7 c 400 8 8 c 300 9 9 c 200 10 10 c 100
#新たな列を追加
df.x$new <- "0"
> df.x id item price new 1 1 a 1000 0 2 2 a 900 0 3 3 b 800 0 4 4 b 700 0 5 5 b 600 0 6 6 c 500 0 7 7 c 400 0 8 8 c 300 0 9 9 c 200 0 10 10 c 100 0
#条件式
df.x[df.x$item == "c" & df.x$price >= 500,]$new <- "ok"
> df.x id item price new 1 1 a 1000 0 2 2 a 900 0 3 3 b 800 0 4 4 b 700 0 5 5 b 600 0 6 6 c 500 ok 7 7 c 400 0 8 8 c 300 0 9 9 c 200 0 10 10 c 100 0