Add columns in R based on condition 3 -


the issue add new column dataframe when condition fulfilled. when first columns 1 1 "hom" , when 0 1 "het" should outputted. appreciate help.

example:

1  1  -->  hom 1  1  -->  hom 0  1  -->  het  1  1  -->  hom 0  1  -->  het 

if these 2 conditions check , checking first column of dataframe sufficient

df <- data.frame(num1 = c(1,0,1), num2 = c(1,1,1)) ifelse(df$num1 == 1,"hom","het") # [1] "hom" "het" "hom" 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -