-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodam.R
52 lines (41 loc) · 1.2 KB
/
odam.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
options(width=80)
options(warn=-1)
options(stringsAsFactors=FALSE)
URLWS <<- 'https://pmb-bordeaux.fr/getdata/'
if (!require("Rodam", quietly = TRUE)) {
require(devtools)
install_github("inrae/Rodam", dependencies = TRUE)
}
#-----
library(Rodam)
#-----
## Get Collection
#-----
get_Collection <- function()
{
collection <- dh$getDataByName('collection')
rownames(collection) <- 1:nrow(collection)
collection
}
#-----
## Get Data from ODAM
#-----
get_data_from_ODAM <- function(dataset, setName, Yname)
{
options(stringsAsFactors=FALSE)
Yvar <- Yname
if (Yname == 'Weight' && dataset == 'FR17GV001') Yvar <- 'FreshMassFruit'
if (Yname == 'Weight' && dataset == 'FR17PP009') Yvar <- 'Weight1'
dh <- new('odamws', URLWS, dataset)
invisible(capture.output(
ds1 <- dh$getSubsetByName(setName)
))
M <- ds1$data[ , c('DayAfterAnthese', Yvar) ]
M <- M[ ! is.na(M[Yvar]), ]
M[,Yvar] <- as.numeric(M[,Yvar])
AVG <- aggregate(. ~ DayAfterAnthese, M, mean)
SDEV <- aggregate(. ~ DayAfterAnthese, M, sd)
if (dataset == 'FR17GV001') AVG[,1] <- as.numeric(gsub("D","",AVG[,1]))
dat <- data.frame(x=AVG[,1], y=AVG[,2], sdev=SDEV[,2])
dat
}