Modérateur : Groupe des modérateurs
Code : Tout sélectionner
EI<-vector("character",1000)
for (i in 1:54)
{
EI[i]<-levels(Ipilimumab$Type.EI_1)[Ipilimumab$Type.EI_1[i]]
EI[i+54]<-levels(Ipilimumab$Type.EI_2)[Ipilimumab$Type.EI_2[i]]
EI[i+54+54]<-levels(Ipilimumab$Type.EI_3)[Ipilimumab$Type.EI_3[i]]
EI[i+54+54+54]<-levels(Ipilimumab$Type.EI_4)[Ipilimumab$Type.EI_4[i]]
EI[i+54+54+54+54]<-levels(Ipilimumab$Type.EI_5)[Ipilimumab$Type.EI_5[i]]
}
Code : Tout sélectionner
valeurs <- c("EICUT" , "EIHEM", "autre", "other")
simu = function() sample(valeurs, 5, rep=T)
df <- data.frame(b = rnorm(5),typ3 = simu(), typ7 = simu(), typ1= simu(), a = 1:5)
df
b typ3 typ7 typ1 a
1 -0.4398432 EIHEM EICUT other 1
2 -1.2710835 autre autre EIHEM 2
3 -1.7094339 other other EIHEM 3
4 1.4926046 other other other 4
5 -0.7926824 EIHEM other other 5
Code : Tout sélectionner
sum(df[, grep("typ", colnames(df))] == "EIHEM")
4
sum(df[, grep("typ", colnames(df))] == "EICUT")
1
Code : Tout sélectionner
sum(Ipilimumab[, grep("Type.EI_", colnames(Ipilimumab))] == "EICUT")
Code : Tout sélectionner
sum(Ipilimumab[, grep("Type.EI_", colnames(Ipilimumab))] == "EICUT", na.rm=TRUE)
Code : Tout sélectionner
sum(Ipilimumab[, 1:5] == "EICUT")
Code : Tout sélectionner
table(unlist(df[,2:3]))
autre EICUT EIHEM other
3 5 1 1
Retourner vers « Questions en cours »
Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 1 invité