base R answer
# Replace '...' with the path to the directory with your files.
files <- list.files(..., pattern="\.csv$", full.names=TRUE)
files <- setNames(files, basename(files))
results <- lapply(files, function(x) {
df <- read.csv(x, stringsAsFactors=FALSE)
result <- glm(
Event ~ T-ctrl + T_out + RH_out + T_stp_cool + T_stp_heat + Humi,
data=df, family=binomial(link="logit")
)
return(result)
})
data.table will speed things up a bit if the files are big and/or you have a lot of files.
library("data.table")
# Replace '...' with the path to the directory with your files.
files <- list.files(..., pattern="\.csv$", full.names=TRUE)
files <- setNames(files, basename(files))
results <- lapply(files, function(x) {
DT <- fread(x, sep=",")
result <- glm(
Event ~ T-ctrl + T_out + RH_out + T_stp_cool + T_stp_heat + Humi,
data=DT, family=binomial(link="logit")
)
return(result)
})