Try lapply(ONS, fft)
and take a look here http://cran.r-project.org/doc/manuals/R-intro.html for the basics of data structures in R and how to apply functions to them. Andy. andydol...@gmail.com 2009/5/27 Linlin Yan <yanlinli...@gmail.com> > Why did you use different variable names rather than index of > list/data.frame? > > On Wed, May 27, 2009 at 6:34 PM, Maithili Shiva > <maithili_sh...@yahoo.com> wrote: > > Dear R helpers, > > > > Following is a R script I am using to run the Fast Fourier Transform. The > csv files has 10 columns with titles m1, m2, m3 .....m10. > > > > When I use the following commands, I am getting the required results. The > probelm is if there are 100 columns, it is not wise to define 100 commands > as fk <- ONS$mk and so on. Thus, I need some guidance to write the loop for > the STEP A and STEP B. > > > > Thanking in advance > > > > Regards > > > > Maithili > > > > > > > > My R Script > > > > > ----------------------------------------------------------------------------------------------- > > > > ONS <- read.csv("fast fourier transform.csv", header = TRUE) > > > > # STEP A > > > > f1 <- ONS$m1 > > > > f2 <- ONS$m2 > > > > f3 <- ONS$m3 > > > > f4 <- ONS$m4 > > > > f5 <- ONS$m5 > > > > f6 <- ONS$m6 > > > > f7 <- ONS$m7 > > > > f8 <- ONS$m8 > > > > f9 <- ONS$m9 > > > > f10 <- ONS$m10 > > > > > #____________________________________________________________________________________________ > > > > > > # STEP B > > > > g1 <- fft(f1) > > > > g2 <- fft(f2) > > > > g3 <- fft(f3) > > > > g4 <- fft(f4) > > > > g5 <- fft(f5) > > > > g6 <- fft(f6) > > > > g7 <- fft(f7) > > > > g8 <- fft(f8) > > > > g9 <- fft(f9) > > > > g10 <- fft(f10) > > > > > > > #____________________________________________________________________________________________ > > > > h <- g1*g2*g3*g4*g5*g6*g7*g8*g9*g10 > > > > j <- fft((h), inverse = TRUE)/length(h) > > > > > > > #____________________________________________________________________________________________ > > > > > > > > > > Cricket on your mind? Visit the ultimate cricket website. Enter > http://beta.cricket.yahoo.com > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.