[R] RES: initialize a matrix

From: Leandro Marino <leandro_at_cesgranrio.org.br>
Date: Fri, 04 Jul 2008 15:42:26 -0300

You have to put the tml in the function and deltat too.

like
VAR<-function(power,length,deltat,tml){

-----Mensagem original-----
De: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org]Em nome de mysimbaa
Enviada em: sexta-feira, 4 de julho de 2008 11:22 Para: r-help_at_r-project.org
Assunto: [R] initialize a matrix

Dear R users,

I'm trying to write a function which returns minimum,maximum,mean of a vector(power)

I've done the following :
VAR<-function(power,length){
for(i in tml:length)){
tvar[i]<-i
pmean[i]<-mean(power[i:i+deltat])
pmin[i]<-min(power[i:i+deltat])
pmax[i]<-max(power[i:i+deltat])
varmax[i]<-100*(pmax[i]-pmean[i])/pmean[i] varmin[i]<-100*(pmean[i]-pmin[i])/pmean[i] Resulats<-list(tvar,pmin,pmax,pmean,varmin,varmax) }}

p.s. tml is a variable which is grater than 0 , deltat is a constant defined

The problem is that tvar is unknown for R. So I have to initialize tvar,pmean...
Should I create a zero matrix with length of the vector? And how to do it?

Thanks for help

--
View this message in context:
http://www.nabble.com/initialize-a-matrix-tp18279886p18279886.html
Sent from the R help mailing list archive at Nabble.com.


______________________________________________
R-help_at_r-project.org 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.
______________________________________________
R-help_at_r-project.org 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.
Received on Fri 04 Jul 2008 - 18:41:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jul 2008 - 20:33:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive