Jan Wantia wrote:

Dear all,

I have a problem with adding columns to a data structure, using 'cbind':

I create an array, to which I want to cbind one new colum for every iteration of a loop. Without the loop, the code works and looks like this:

 > Min<- array(0,c(129,0))
 > Min

 [1,]
 [2,]
 [3,]
 [4,]
 etc..

 >  file <- paste("Path\\to\\file\\Run_1", sep="")
 >  Tabelle <- read.table(file, sep=";", skip = 8)
 >  cbind(Min, Tabelle[,(which.min(Tabelle[129,]))])
       [,1]
 [1,] 25.45
 [2,] 25.33
 [3,] 25.76
 [4,] 25.40
 [5,] 24.39
 etc.

However, with the loop the result is the following:

 > for(i in 1:2){
+ file <- paste("Path\\to\\file\\Run_",i, sep="")
+ Tabelle <- read.table(file, sep=";", skip = 8)
+ cbind(Min, Tabelle[,(which.min(Tabelle[129,]))])

You probably want

Min <- cbind(Min, Tabelle[,(which.min(Tabelle[129,]))])

Also, read the posting guide which will tell you the following:

"For new subjects, compose a new message and include the '[EMAIL PROTECTED]' (or '[EMAIL PROTECTED]') address specifically. (Replying to an existing post and then changing the subject messes up the threading in the archives and in many people's mail readers.)"

--sundar

______________________________________________
[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

Reply via email to