[R] Error in for-loop

Domi dominic.roye at gmail.com
Sun Jul 29 15:59:11 CEST 2012

Hello erverybody, 

I have a problem with my second for-loop. 

1. First i read the tables.

datos.mx1 <- read.table('PETmx1.csv',head=TRUE,sep=';')
datos.min <- read.table('PETmin.csv',head=TRUE,sep=';')

http://r.789695.n4.nabble.com/file/n4638257/PETmx1.csv PETmx1.csv 
http://r.789695.n4.nabble.com/file/n4638257/PETmin.csv PETmin.csv 


 "Fecha"              "Mes"                "Serra.da.Foladoira"          
"Santiago"           "Sergude"            "Rio.Do.Sol" 

You find in the first column the date and in the second only the month. The
other columns contain the temperature of the respective weather stations. 

2.  My aim is to calculate thresholds for each weather station.

superior <- NULL
inferior <- NULL

for (i in 3:6){
superior[i] <- 23+(datos.mx1[i]-23)*0.33;
inferior[i] <- 18+(datos.min[i]-18)*0.33;

#Until here everything is ok, but the next loop issues an error. I must
multiply the results of each weather station with a constant.

for (i in 3:6){

LF[i] <- 1.26086956521739*superior[[i]];
LC[i] <- 0.722222222222222*inferior[[i]]

The error is: "Number of items to replace is not a multiple of replacement

I hope someone can help me. I thank you very much. 

Best regards,


View this message in context: http://r.789695.n4.nabble.com/Error-in-for-loop-tp4638257.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list