-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_Rsquared_summary.R
More file actions
21 lines (20 loc) · 1.03 KB
/
4_Rsquared_summary.R
File metadata and controls
21 lines (20 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/R
library(xlsx)
lapply(c("all/outputs","randomForest_reduced/outputs"), function(analysis){
files <- list.files(analysis,recursive=T,pattern="*.xls")
data <- lapply(files, function(file){
# get EZG identifiers by GIS_ID
region <- sub("results__(plateau|alps).*","\\1",basename(file))
response <- sub("results__(plateau|alps)_(.*)_zero.*","\\2",basename(file))
resp_vec <- rep(c(response,paste0(response,"_log")),each=2)
fit_vec <- rep(c("cross-validated","fit_on_all_data"),2)
method <- dirname(file)
# check which model is the best
x <- read.xlsx(file.path(analysis,file),sheetName="stats")
retData <- cbind(region,method,resp_vec,fit_vec,round(as.numeric(x$R.2),4))
colnames(retData) <- c("region","method","response","fit","Rsquared")
return(retData)
})
outData <- as.data.frame(Reduce(rbind,data))
write.table(outData,file.path(analysis,paste0(dirname(analysis),"_Rsquared_summary.tsv")),row.names=F,quote=F,sep="\t")
})