lundi 27 juillet 2020

Determine a characteristic by evaluating two df - R

Hi, I've been working with two df, one is the information recollected at the field and the other one it's like a diagnose table

Name<-c("Mario", "Pedro", "Julia", "Jazmin")
Weight<-c("110","50","67","80")
Pacients<- data.frame(Name, Weight)

 Pacients$Name $Weight
  <fct>         <fct>  
1 Mario         110    
2 Pedro         50     
3 Julia         67     
4 Jazmin        80  

Min_W<-c("45", "66", "76", "86", "101")
Max_W<-c("65","75","85","100","150")
Dx<-c("underw","inrange","preob","ob","morb")
W_Table<- data.frame(Min_W, Max_W, Dx)

W_Table$Min_W $Max_W $Dx    
  <fct>         <fct>  <fct>  
1 45            65     underw 
2 66            75     inrange
3 76            85     preob  
4 86            100    ob     
5 101           150    morb   

I've been trying with functions like mutate and ifelse but I keep having problems with returning just one value. The return should look something like this

Pacients_Dx$Name $Weight $Dx    
  <fct>            <fct>   <fct>  
1 Mario            110     morb   
2 Pedro            50      underw 
3 Julia            67      inrange
4 Jazmin           80      preob   

Thanks

Aucun commentaire:

Enregistrer un commentaire