hello,
I'm trying to write a function which take a matrix and give a dataframe with 
column names and row names but the problem I meet it's that the column number 
is changing and the vector containing the column names is also changing how can 
I do to write a good progam for the moment I tryied like follow:

dm <- ncol(M)
v <- vector()
t <- 1
while (dm > 0) {
 v <- c(v,paste("Rép",t,sep=""))
 t <- t + 1
 dm <- dm - 1
}
nv <- noquote(v)
df <- function (M,x) {
 return(data.frame(nv[1] = M[,1], nv[2] = M[,2],nv[3] = M[,3], row.names = 
var[[1]], check.rows = TRUE, check.names = TRUE))
}

 I know that there are errors but the important is that R doesn't recognize nv.
For more precision the martix M is like follow:

 M
      [,1] [,2] [,3]
 [1,] 6.52   NA 6.59
 [2,] 6.99 6.85 6.38
 [3,] 6.92 6.72 6.99
 [4,] 6.59 5.51 6.45
 [5,] 6.65 7.12 6.99
 [6,] 6.18 5.71 5.78
 [7,] 6.65 6.52 6.72
 [8,] 6.65 6.79 6.12
 [9,] 6.59 6.65 6.32
[10,] 5.85 6.05 6.38
[11,] 6.38 6.79 6.65
[12,] 6.79 6.52 6.72
[13,] 6.12 6.25 6.38
[14,] 6.99 6.72 6.38
[15,] 6.59 6.65 6.99
[16,] 6.45 6.18 6.59
[17,] 5.65 6.05 6.52
[18,] 6.52 6.85 6.65
[19,] 6.18 6.32 6.32
[20,] 6.99 6.65 6.72
[21,] 6.52 6.99 6.32

Can you help me?
thanks.


      
_____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to