merge with solaR

[This article was first published on Omnia sunt Communia! » R-english, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The version 0.22 of solaR includes a new method, mergesolaR. It is designed to merge daily time series of several solaR objects.
For example, we can obtain the daily irradiation of the whole set of meteorological stations of Madrid (Spain) and use this information to calculate the productivity of a grid connected PV system. It is possible to complete this process with the lapply function. Therefore, we obtain a list of ProdGCPV objects:

EstMadrid <- subset(RedEstaciones, NomProv=='Madrid')
nEstMadrid <- nrow(EstMadrid)
namesMadrid <- EstMadrid$NomEst

prodMadrid <- lapply(1:nEstMadrid,
 function(x){try(prodGCPV(lat=41, modeRad='mapa',
 mapa=list(prov=28, est=x,
 start='01/01/2009', end='31/12/2010'))
names(prodMadrid) <- namesMadrid
okMadrid <- lapply(prodMadrid, class)!='try-error'
prodMadrid <- prodMadrid[okMadrid]

In order to prevent from the erroneous behaviour of some stations, the code includes the use of try.

Now it’s time for mergesolaR. Since we have a list of objects, can solve the problem:

YfMadrid <-, prodMadrid)

The mergesolaR for a set of ProdGCPV objects merges the daily time series of the Yf variable of each object. The result is a multivariate zoo object which can be displayed (for example) with the horizonplot function.

Previously, the row mean is substracted from each column in order to show the deviation of each meteorological station from the daily mean of the set of stations.


Besides, the function TargetDiagram is an alternative tool to show the behaviour of
the set of meteorological stations:

TargetDiagram(YfMadrid, end=as.POSIXct('2010-12-31'), ndays=c(10, 20,
30, 40, 50, 60))

To leave a comment for the author, please follow the link and comment on their blog: Omnia sunt Communia! » R-english. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)