setwd("Put the path of your working folder here") myfile1 <- list.files() j <- 1 for (i in myfile1) { df <- read.csv(i) x <- na.omit(df$Event) neg <- sum(x[x<0]) countneg <- sum(x<0) pos <- sum(x[x>0]) countpos <- sum(x>0) print (c(countpos, countneg, pos, neg, pos+neg, pos-neg)) j <- j+1 }