ok how can I do to cancel le function factor for the moment ican't do this
and I'm stuck with my problem for exemple
Id_Rep Id_Geno Val_O Id_TrT1
1 1 64238 145 2
2 1 64238 1 1
3 1 64238 2 1
4 1 64238 1 1
5 1 64238 1 1
6 1 64238 2 1
7 1 64238 1 1
8 2 64238 1 1
9 2 64238 2 1
10 2 64238 1 1
11 2 64238 1 1
12 2 64238 1 1
13 2 64238 1 1
14 1 64239 144 2
15 1 64239 1 1
but when I write like below I have still levels and I'd like to disappear
levels
don[1:15,]$Val_O
[1] 145 1 2 1 1 2 1 1 2 1 1 1 1 144 1
127 Levels: 1 10 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11 11.1 11.2 11.3
11.4 11.5 11.6 11.7 11.8 11.9 12 12.1 12.2 12.3 12.4 12.5 12.6 12.7 ... 9.9
---------------------------------
[[alternative HTML version deleted]]
?as.numeric
-----Message d'origine-----
De?: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at
stat.math.ethz.ch] De la part de elyakhlifi mustapha
Envoy??: jeudi 19 avril 2007 15:30
??: R-help at stat.math.ethz.ch
Objet?: [R] hello
ok how can I do to cancel le function factor for the moment ican't do this
and I'm stuck with my problem for exemple
Id_Rep Id_Geno Val_O Id_TrT1
1 1 64238 145 2
2 1 64238 1 1
3 1 64238 2 1
4 1 64238 1 1
5 1 64238 1 1
6 1 64238 2 1
7 1 64238 1 1
8 2 64238 1 1
9 2 64238 2 1
10 2 64238 1 1
11 2 64238 1 1
12 2 64238 1 1
13 2 64238 1 1
14 1 64239 144 2
15 1 64239 1 1
but when I write like below I have still levels and I'd like to disappear
levels
don[1:15,]$Val_O
[1] 145 1 2 1 1 2 1 1 2 1 1 1 1 144 1
127 Levels: 1 10 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11 11.1 11.2 11.3
11.4 11.5 11.6 11.7 11.8 11.9 12 12.1 12.2 12.3 12.4 12.5 12.6 12.7 ... 9.9
---------------------------------
[[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.
francois.morneau at ifn.fr wrote:> ?as.numericin response to> ok how can I do to cancel le function factor for the moment ican't do > this and I'm stuck with my problem for exemple....... <snip> The use of as.numeric() to convert a factor to a numeric vector is fraught with peril. E.g. > f <- factor(rep(2*(1:5),3)) > f [1] 2 4 6 8 10 2 4 6 8 10 2 4 6 8 10 Levels: 2 4 6 8 10 > as.numeric(f) [1] 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 which is probably not what one was expecting or wanting. However you *can* get what you want: > as.numeric(as.character(f)) [1] 2 4 6 8 10 2 4 6 8 10 2 4 6 8 10 cheers, Rolf Turner rolf at math.unb.ca P.S. To save myself key-strokes I have written a wee function f2n <- function(x){as.numeric(as.character(x))} R. T.
look at R FAQ 7.10
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "elyakhlifi mustapha" <elyakhlifi_mustapha at yahoo.fr>
To: <R-help at stat.math.ethz.ch>
Sent: Thursday, April 19, 2007 3:29 PM
Subject: [R] hello
> ok how can I do to cancel le function factor for the moment ican't
> do this and I'm stuck with my problem for exemple
>
> Id_Rep Id_Geno Val_O Id_TrT1
> 1 1 64238 145 2
> 2 1 64238 1 1
> 3 1 64238 2 1
> 4 1 64238 1 1
> 5 1 64238 1 1
> 6 1 64238 2 1
> 7 1 64238 1 1
> 8 2 64238 1 1
> 9 2 64238 2 1
> 10 2 64238 1 1
> 11 2 64238 1 1
> 12 2 64238 1 1
> 13 2 64238 1 1
> 14 1 64239 144 2
> 15 1 64239 1 1
>
> but when I write like below I have still levels and I'd like to
> disappear levels
>
>
> don[1:15,]$Val_O
> [1] 145 1 2 1 1 2 1 1 2 1 1 1 1 144 1
> 127 Levels: 1 10 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11
> 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 12 12.1 12.2 12.3 12.4
> 12.5 12.6 12.7 ... 9.9
>
>
>
> ---------------------------------
>
> [[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.
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
hello, I have a problem with a R program I don't understand my errors my program looks like this> for(i in LE) {+ for(j in LEC[[i]]) { + for(k in LR) { + donRep[[k]] <- subset(don2, Id_Essai == 1006961 & Id_Cara == j & Id_Rep == k & Id_Geno != 65125, select = Val_O) + M[[j]] <- matrix(rep(1, 3*length(donRep[[1]][,1])), nrow =length(donRep[[1]][,1]), ncol = 3) + for(k in LR) { + M[[j]][,k] <- as.numeric(as.character(donRep[[k]][,1])) + } + } + print(M[[j]]) + if (subset(donParCara, Id_Cara == j , select = Ana_C) == "AV") + {print(cor(M[[j]], method = "pearson"))} else{print(cor(M[[j]], method = "spearman"))} + } + } Erreur dans M[[j]][, k] <- as.numeric(as.character(donRep[[k]][, 1])) : le nombre d'objets à remplacer n'est pas multiple de la taille du remplacement and sometimes it run good but sometimes there are errors I don't understand why. Can you help me please? ___________________________________________________________________________ [[alternative HTML version deleted]]