[R] Odp: hi

Petr PIKAL petr.pikal at precheza.cz
Thu May 3 14:44:34 CEST 2007


Hi

r-help-bounces at stat.math.ethz.ch napsal dne 03.05.2007 14:01:27:

> hi,
> I have a problem to use union function because one of the elements is a 
> character and the others are numeric 
> 
> > for(j in 1:length(I)) {
> + C1 <- levels(factor(subset(donParEssai, Id_Essai == 1006961 & Id_Cara 
== 
> I[j], select = Date_O)[,1]))
> + C2 <- as.numeric(levels(factor(subset(donParEssai, Id_Essai == 1006961 
& 
> Id_Cara == I[j], select = Stade_O)[,1])))
> + C3 <- length(as.numeric(levels(factor(subset(donParEssai, Id_Essai == 
> 1006961 & Id_Cara == I[j], select = Id_Geno)[,1]))))
> + C4 <- length(levels(factor(subset(donParEssai, Id_Essai == 1006961 & 
Id_Cara
> == I[j], select = Id_Rep)[,1])))
> + C5 <- mean(as.numeric(as.character(subset(donParEssai, Id_Essai == 
1006961 &
> Id_Cara == I[j], select = Val_O)[,1])))
> + C6 <- range(as.numeric(as.character(subset(donParEssai, Id_Essai == 
1006961 
> & Id_Cara == I[j], select = Val_O)[,1])))
> + C7 <- sd(as.numeric(as.character(subset(donParEssai, Id_Essai == 
1006961 & 
> Id_Cara == I[j], select = Val_O)[,1])))
> + RecapCara[j,] <- 
union(C1,union(C2,union(C3,union(C4,union(C5,union(C6,C7))))))
> + }
> Erreur dans RecapCara[j, ] <- union(C1, union(C2, union(C3, union(C4, 
union(C5,  : 
>         le nombre d'objets ŕ remplacer n'est pas multiple de la taille 
du remplacement
> > print(RecapCara)
>      [,1] [,2] [,3]     [,4] [,5] [,6]     [,7]
> [1,]   NA   21    3  7.66129  5.2 17.1 2.318801
> [2,]   NA   21    3 50.56774 47.3 53.9 1.469222
> 
> > C1
> [1] "29/08/2005"
> 
> I can't paste C1 with others values how could I do to paste C1 with 
others please?

Change it to numeric?

Regards
Petr

> 
> 
> 
> 
___________________________________________________________________________
> 
> 
> 
> 
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list