Modérateur : Groupe des modérateurs
Code : Tout sélectionner
> by(Don[,"Distance"],Don[,"Sexe"],sum)
Error in by(Don[, "Distance"], Don[, "Sexe"], sum) :
object 'Don' not found
Code : Tout sélectionner
> Don <- data.frame(Sexe="Garçon",Distance=130.3)
> by(Don[,"Distance"],Don[,"Sexe"],sum)
Don[, "Sexe"]: Garçon
[1] 130.3
Code : Tout sélectionner
base::by(data = Don[, "Distance"], INDICES = Don[, "Sexe"], FUN = mean)
Code : Tout sélectionner
> Don <- read.table("http://math.agrocampus-ouest.fr/math/husson/StatUtilisateurExo/chap3_ex4.csv", header = TRUE,sep=";")
> base::by(data = Don[, "Distance"], INDICES = Don[, "Sexe"], FUN = mean)
Don[, "Sexe"]: Filles
[1] 12.28
-------------------------------------------------------------------------------------------------------------
Don[, "Sexe"]: Garçon
[1] 10.85833
> by(Don[,"Distance"],Don[,"Sexe"],summary)
Don[, "Sexe"]: Filles
Min. 1st Qu. Median Mean 3rd Qu. Max.
10.40 10.88 12.35 12.28 13.35 14.50
-------------------------------------------------------------------------------------------------------------
Don[, "Sexe"]: Garçon
Min. 1st Qu. Median Mean 3rd Qu. Max.
9.20 9.70 10.50 10.86 11.72 13.70
Code : Tout sélectionner
> mean=12
> base::by(data = Don[, "Distance"], INDICES = Don[, "Sexe"], FUN = mean)
Error in FUN(dd[x, ], ...) : impossible de trouver la fonction "FUN"
Code : Tout sélectionner
> Don <- read.table("http://math.agrocampus-ouest.fr/math/husson/StatUtilisateurExo/chap3_ex4.csv", header = TRUE,sep=";")
> base::by(data = Don[, "Distance"], INDICES = Don[, "Sexe"], FUN = mean)
Don[, "Sexe"]: Filles
[1] 12.28
-------------------------------------------------------------------------------------------------------------
Don[, "Sexe"]: Garçon
[1] 10.85833
> by(Don[,"Distance"],Don[,"Sexe"],summary)
Don[, "Sexe"]: Filles
Min. 1st Qu. Median Mean 3rd Qu. Max.
10.40 10.88 12.35 12.28 13.35 14.50
-------------------------------------------------------------------------------------------------------------
Don[, "Sexe"]: Garçon
Min. 1st Qu. Median Mean 3rd Qu. Max.
9.20 9.70 10.50 10.86 11.72 13.70
Code : Tout sélectionner
> mean=12
> base::by(data = Don[, "Distance"], INDICES = Don[, "Sexe"], FUN = mean)
Error in FUN(dd[x, ], ...) : impossible de trouver la fonction "FUN"
Code : Tout sélectionner
mean
Code : Tout sélectionner
function (x, ...)
UseMethod("mean")
<bytecode: 0x557d1440c0b0>
<environment: namespace:base>
Michel Carpentier a écrit :merci pour votre aide.
j'ai compris qu'il ne faut jamais utiliser le nom d'une fonction comme variable.
Code : Tout sélectionner
base::by(data = Don[, "Distance"], INDICES = Don[, "Sexe"], FUN = base::mean)
Retourner vers « Questions en cours »
Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 1 invité