大家好,新手入门,刚刚开始学R,目前这个问题搞不定,请问如何操作?
首先我用data.frame()建立一个test,其中的一列是test1
> test <- data.frame(test1=c(c(0.00, 0.005, 0.01, 0.015, 0.02)))
> test
test1
1 0.000
2 0.005
3 0.010
4 0.015
5 0.020
现在我想要建立另一列test2
for i=c(1:5), If test$test1 is 0, then the value of test$test2 is 1/test1
or else If test$test1 is not 0, then the value of test$test2 is 39
请问这一步如何实现?
非常感谢!