[R] how to apply the same function to multiple data set

Rui Barradas ruipbarradas at sapo.pt
Wed Jun 27 13:48:01 CEST 2012


Hello,

Try the following.

estIID50 <- apply( IID50, 2, function(x) pargev(lmom.ub(x)) )

And see ?apply

Hope this helps,

Rui Barradas

Em 27-06-2012 12:31, Al Ehan escreveu:
> Hi R-users,
>
> I'm trying to repeat the same procedure to 1000 data set. I know this is
> very easy, but I got stuck finding the right and fastest way in running it.
>
> IID50=Riidf[1:50,1:1000] #where IID50 is a dataframe consist of 1000 time
> series(as column) and 50 time scales (row).
>
> #what I tried to do:
>
> estIID50=rep(NA,1000)
> for (i in 1:1000)
> estIID50[i]=pargev(lmom.ub(IID50[1:50,i]))
>
> #warning message
>   In estIID50[i] = pargev(lmom.ub(IID50[1:50, i])) :
>    number of items to replace is not a multiple of replacement length
>
> #pargev is a function from lmomco package. I would like to apply it to the
> 1000 set of time series that I have in the IID50, without having to do it
> manually.
> #I dont understand what is the warning warns about
>
> Can somebody help me?
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list