merge with remote
[aggexp.git] / pkg / R / z_getData.R
index b4dd2ba..43c458b 100644 (file)
@@ -1,69 +1,23 @@
-expertsArray = c(
-       "CLM", #1
-       "GAM", #2
-       "CLM1", #3
-       "CLM2", #4
-       "S_AIRPARIF", #5
-       "S_INERIS", #6
-       "D_ESMERALDA", #7
-       "D_PREVAIR", #8
-       "D_PREVAIR2", #9
-       "PERSIST", #10
-       #new additions only for PQV_2014
-       #TODO: default behavior on station != PQV_2014 ?
-       "GAM_sepMar", #11
-       "GAM_aprAug", #12
-       "GAM_highPollution", #13
-       "GAM_lowPollution", #14
-       "GAM_hotTemperature", #15
-       "GAM_coldTemperature", #16
-       "GAM_eastWind", #17
-       "GAM_westWind", #18
-       "GAM_noRain", #19
-       "GAM_rain" #20
-)
-
-stationsArray = c(
-       "AIL", #1
-       "ALE", #2
-       "CAE", #3
-       "CHD", #4
-       "EVT", #5
-       "HRI", #6
-       "IFS", #7
-       "JUS", #8
-       "LIS", #9
-       "MAS", #10
-       "MRA", #11
-       "NEI", #12
-       "POS", #13
-       "PQV", #14
-       "SLO", #15
-       "HRI_2014", #16
-       "LIS_2014", #17
-       "PQV_2014", #18
-       "PQV2" #19
-)
-
 #' @title Get forecasts + observations
 #'
 #' @description Get forecasts of all specified experts for all specified stations, also with (ordered) dates and (unordered) stations indices.
 #'
-#' @param experts Names of the experts. Default: all
-#' @param station Names of the stations. Default: all
+#' @param station List of stations dataframes (as in the sample)
+#' @param experts Names of the experts (as in dataframe header)
 #'
 #' @export
-getData = function(experts=expertsArray, stations=stationsArray)
+getData = function(stations, experts)
 {
-       #no need because of "LazyData: true" in DESCRIPTION
-       #data(list=stations, package="aggexp")
        data = as.data.frame(matrix(nrow=0, ncol=1 + length(experts) + 2))
        names(data) = c("Date", experts, "Measure", "Station")
        for (i in 1:length(stations))
        {
-               stationInfo = get(stations[i])
                #date index is sufficient; also add station index
-               stationInfo = cbind(Date = 1:nrow(stationInfo), stationInfo[,names(stationInfo) %in% experts], Measure = stationInfo[,"Measure"], Station = i)
+               stationInfo = cbind(
+                       Date = 1:nrow(stations[[i]]),
+                       stations[[i]] [,names(stations[[i]]) %in% experts],
+                       Measure = stations[[i]][,"Measure"],
+                       Station = i)
                data = rbind(data, stationInfo)
        }