[R] write result in matrix using loop

Grześ gregorio99 at gmail.com
Thu Aug 13 23:15:08 CEST 2009

I want call my function (use my database) and write every result in matrix
"wynik" but I always get an error: Error in wynik[, i] <- dodawanie(wzorzec,
wzorzec1) : 
  number of items to replace is not a multiple of replacement length

I'll be very happy if sb help me

dodawanie<- function ( wzorzec, wzorzec1){ 
wynik1<-wzorzec + wzorzec1 
wynik2<-wzorzec * wzorzec1 
wynik <- c(wynik1,wynik2) 
return (wynik) 

df=data.frame(a=c(1,2,3),b=c(9,9,9),c=c(4,3,2)) # This is my database ;) 


# and my loop 
for(i in 1:ncol(df)){ 
procent_graniczny <- 10 
wynik[,i] <- dodawanie ( wzorzec, wzorzec1)        #  <-  Here is my problem
!!! I want in "wynik" have got result from my function (one by one)

View this message in context: http://www.nabble.com/write-result-in-matrix-using-loop-tp24958820p24958820.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list