Programming Beginner

#1
Hi,

Can i get some help in writing a code.

I have 3 csv files, 6 columns in each file.

1) I need to take average of each column in each file separately. ~ 6 values per file
2) find minimum average value for each column across all 3 files (min value of average across the three files for column 1) ~ 6 values in all
3) Plot the minimum average values for each column

function1<-function(filename)
{dat<-read.csv(file=filename,header=FALSE)
avg_percolumn<-apply(dat,2,mean)
min_averagevalue<-min(avg_percolumn)

dev.new(plot(min_averagevalue))}

##how to apply min operation for each column separately for all files? As in column 2 minimum average value for 3 files. Above statement takes min across all columns.

filelist<-list.files(pattern="names",full.names=TRUE)
for (i in filelist)
{dev.new(function1(i)}
 
#2
Hey for min you have to loop through the columns of your cvs.

Adressing specific data is done by dat[x,y] so for dat[x,] you get the row x and dat[,y] gives you colunm y

so using a for statement and in each iteration you use the next column.

Or just as you did with mean use apply(dat,2,min)