Thank you for the answer, but I did´n find the solution. I'm a bit lost,
cos I am a beginner in R. I hope you can give me a little bit more help.



2012/7/29 jholtman [via R] <ml-node+s789695n4638270h61@n4.nabble.com>

> Try this:  You had some 'indexing' problems.  You were accessing the
> columns of the dataframe incorrectly.  You are also accessing 'list'
> so you might want to review the Intro to R on indexing:
>
> > datos.mx1 <- read.table('
> http://r.789695.n4.nabble.com/file/n4638257/PETmx1.csv',head=TRUE,sep=';')
>
> > datos.min <- read.table('
> http://r.789695.n4.nabble.com/file/n4638257/PETmin.csv',head=TRUE,sep=';')
>
>
> >
> > superior <- NULL
> > inferior <- NULL
> > LC <- NULL
> > LF <- 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]]
> + }
> > str(LF)
> List of 6
>  $ : NULL
>  $ : NULL
>  $ : num [1:1826] 21.1 21.7 23.5 23.5 23.7 ...
>  $ : num [1:1826] 25.4 23.5 24.8 25 24.5 ...
>  $ : num [1:1826] 23.3 24 24.7 24.7 24.9 ...
>  $ : num [1:1826] 21.8 22.6 23.5 23.5 22.8 ...
> > str(LC)
> List of 6
>  $ : NULL
>  $ : NULL
>  $ : num [1:1826] 7.83 8.5 8.21 7.83 8.28 ...
>  $ : num [1:1826] 9.07 9.76 8.54 8.07 9.35 ...
>  $ : num [1:1826] 8.66 8.95 8.61 7.61 9.12 ...
>  $ : num [1:1826] 8.07 8.69 8.07 7.85 8.23 ...
>
> On Sun, Jul 29, 2012 at 9:59 AM, Domi <[hidden email]<http://user/SendEmail.jtp?type=node&node=4638270&i=0>>
> wrote:
>
> > 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
> >
> > names(datos.mx1)
> >
> >  "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
> > LC <- NULL
> > LF <- 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
> > length".
> >
> >
> > I hope someone can help me. I thank you very much.
> >
> > Best regards,
> >
> > Domi
> >
> >
> >
> >
> >
> >
> > --
> > 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.
> >
> > ______________________________________________
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4638270&i=1>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.
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
> ______________________________________________
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4638270&i=2>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.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/Error-in-for-loop-tp4638257p4638270.html
>  To unsubscribe from Error in for-loop, click here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4638257&code=ZG9taW5pYy5yb3llQGdtYWlsLmNvbXw0NjM4MjU3fC0xMDE1MzU3MDM1>
> .
> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://r.789695.n4.nabble.com/Error-in-for-loop-tp4638257p4638699.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]

