#How to extra and transform the data from the 'Belgium' dataset
## Libraries ################################################
library(reshape2)
library(dplyr)
library(DImodelsMulti)
#############################################################
## Read in data##################################
data("Belgium")
#############################################################
## Standardise responses for Analysis 1 (RM) #################
Belgium_RM <- Belgium
#Top 9 values
top <- Belgium_RM %>%
arrange(desc(Y)) %>%
group_by(Var) %>%
slice(1:9)
#Average of top values
top <- aggregate(Y ~ Var, data = top, FUN = "mean")
Belgium_RM$Y <- 100*Belgium_RM$Y
#Sown
condition <- which(Belgium_RM$Var == "Sown")
Belgium_RM$Y[condition] <- Belgium_RM$Y[condition] /
top[1, "Y"]
#Subset to just the Sown response
Belgium_RM <- Belgium_RM[which(Belgium_RM$Var == "Sown"), ]
Belgium_RM
Run the code above in your browser using DataLab