I have 58 data named as: h5, h6,... h64. I want to run following script on all of them at one time and save the result in 1 new data file. this is my script:
t <- read.table("h5",header = F, row.names=1)
cor(t)
(cor(t))^2
lm(t$V3 ~ t$V2, data=t)
I know for reading all the data files at once I can use :
myFiles <- list.files(pattern="h.*")
But for the rest I do not know how to make a loop or how to store the result in a new data frame. any suggestion?
I show in below my input file structure :
HO840M3000540481 993.38 1543.1765
HO840M3000540483 -0.51 1120.8224
HO840M3000540497 1192.06 1651.3322
HO840M3004672697 388.5 1140.0917
HO840M3004672704 426.9 836.3676
HO840M3006005895 524.65 1301.8218
HO840M3006972816 1673.99 1389.1919
HO840M3006988837 188.35 385.6415
HO840M3006988891 2987.58 1919.2762
HO840M3006989113 1097.59 1746.4724
HO840M3007701817 1320.5 1058.4915
HO840M3007701858 -372.15 1090.6167
HO840M3007815980 548.58 759.3870
write.table(x, file = "", append = TRUE)