I have a dataframe called g1
. It has 3 columns that are factors: max_num
, max_res
and g1$bdest
. I have a number N = 8
. I would like to create a new column with name g1$WMA
. For each row: in case g1$max_num > N/2
I would like g1$WMA
to get the value g1$max_res
otherwise - g1$bdest
. I used the following command, however I get a wrong computation:
g1$WMA = ifelse ( (( as.numeric(as.character(g1$max_num) ) )> (N/2)), g1$max_res, g1$bdest)
How can I correct it?
Aucun commentaire:
Enregistrer un commentaire