generate column values with multiple conditions in R

后端 未结 8 2045
甜味超标
甜味超标 2020-12-29 00:22

I have a dataframe z and I want to create the new column based on the values of two old columns of z. Following is the process:

&g         


        
8条回答
  •  生来不讨喜
    2020-12-29 00:39

    I really liked the answer "dinre" posted to flodel's blog:

    for (i in 1:length(data_Array)){
    data_Array[i] <- switch(data_Array[i], banana="apple", orange="pineapple", "fig")
    }
    

    With warnings about reading the help page for switch carefully for integer arguments.

提交回复
热议问题