i need some help with my if else function. I want R to print for every raw in my column (DipE) the corresponding value defined in my if else function.
This is my column:
| TierLID | DipE |
|---|---|
| MLS289 | -4.0020 |
| MLS440 | -3.9680 |
| MLS382 | -3.9280 |
| MLS414 | -3.9280 |
| MLS290 | -2.8480 |
| MLS175 | -2.5210 |
| MLS232 | -2.5020 |
| MLS241 | -2.5020 |
| MLS189 | -2.4040 |
| MLS563 | -2.4040 |
| MLS209 | -2.4000 |
| MLS277 | -0.7396 |
| MLS514 | -0.5619 |
| MLS539 | -0.4518 |
| MLS540 | -0.4518 |
| MLS200 | -0.3709 |
| MLS340 | -0.2090 |
This is my code:
if(Sheeps_with_Haplotyp10$DipE >-4 & <-3.5){ print("1") }else if (Sheeps_with_Haplotyp10$DipE >-3.5 & <-3.0){ print("3") }else if (Sheeps_with_Haplotyp10$DipE >-3.0 & <-2.5){ print("0") }else if (Sheeps_with_Haplotyp10$DipE >-2.5 & <-2.0){ print("4") }else if (Sheeps_with_Haplotyp10$DipE >-2.0 & <-1.5){ print("3") }else if (Sheeps_with_Haplotyp10$DipE >-1.5 & <-1.0){ print("0") }else if (Sheeps_with_Haplotyp10$DipE >-1.0 & <-0.5){ print("2") }else if (Sheeps_with_Haplotyp10$DipE >-0.5 & <-0.0){ print("4") } all it prints is just 4
https://stackoverflow.com/questions/66471473/if-else-function-for-columns March 04, 2021 at 04:44PM
没有评论:
发表评论