I have been trying to create a column for a dataframe where each new observation depends on the value of the observations of other columns. I tried to come up with code that would do that but haven't been any lucky
I also checked these answers ) but couldn't make them work if anyone has an idea on how to do it I would be truly grateful
for (dff$prcganancia in dff){
if(dff$grupo == 1){
prcganancia == 0.3681
}elseif(dff$grupo == 2){
prcganancia == 0.2320
}elseif(dff$grupo == 3){
prcganancia == 0.2851
}elseif(dff$grupo == 4){
prcganancia == 0.4443
}elseif(dff$grupo == 5){
prcganancia == 0.3353
}elseif(dff$grupo == 6){
prcganancia == 0.2656
}elseif(dff$grupo == 7){
prcganancia == 0.2597
}elseif(dff$grupo == 8){
prcganancia == 0.2211
}elseif(dff$grupo == 9){
prcganancia == 0.3782
}elseif(dff$grupo == 10){
prcganancia == 0.3752}
}
What my lousy code is trying to do is make the observation for prcganancia where grupo equals to 1, 0.3681 (every obsrvation where grupo == 1 the observation for prcganancia == 0.3681) and so on