Dear Sir, Thank you very much for such an excellent solution to my problem. I was trying sapply function since last days, but was really unable to write properly. Now, I understood my mistake in using sapply function in the code. Therefore, I have two queries regarding this which I want to discuss here just for my learning purpose.
1. While using sapply function for estimating one method across the columns of a data frame, one needs to define the list of the output table after using sapply so that the test results for each column will be consistently stored in an output object, right? 2. In the spout<- list() command, what spout[[i-1]] indicates? Sir, one more possibility which I would like to ask related to my above problem just to learn for further R programming language. After running your suggested code, all the results for each column are being stored in the spout object. From this, I need only the statistics and P-value for each column. So, my queries are: 1. Is there any way to extract only two values (i.e., statistics and p-value) for each column that stored in spout object and save these two values in another R data frame for each column? or 2. Is there any possibility that the statistics and p-value calculated for each column can directly export to a word file in a table format (having 4 columns and 3 rows). In particular, is it possible to extract both statistic and p-value results for each column to an MS word file with the format of A1, A2, A3, A4 column results in 1st row, A5, A6, A7, A8 column results in 2nd row, and A9, A10, A11, A12 column results in the 3rd row of the table? Like before, your suggestion will definitely help me to learn the advanced R language. Thank you very much for your help. [image: Mailtrack] <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender notified by Mailtrack <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 05/08/20, 03:47:26 PM On Fri, May 8, 2020 at 2:37 PM Jim Lemon <drjimle...@gmail.com> wrote: > Hi Subhamitra, > This isn't too hard: > > # read in the sample data that was > # saved in the file "sp_8_5.tab" > sp_8_5<-read.table("sp_8_5.tab",sep="\t", > header=TRUE,stringsAsFactors=FALSE) > library(tseries) > library(FinTS) > # using "sapply", run the test on each column > spout<-sapply(sp_8_5[,2:12],ArchTest) > > The list "spout" contains the test results. If you really want to use a > loop: > > spout<-list() > for(i in 2:12) spout[[i-1]]<-ArchTest(sp_8_5[,i]) > > Jim > > > On Fri, May 8, 2020 at 5:27 PM Subhamitra Patra < > subhamitra.pa...@gmail.com> wrote: > >> Dear Sir, >> >> Herewith I am pasting a part of my sample data having 12 columns below, >> and want to calculate ARCH test for the 12 columns by using a loop. >> >> -- *Best Regards,* *Subhamitra Patra* *Phd. Research Scholar* *Department of Humanities and Social Sciences* *Indian Institute of Technology, Kharagpur* *INDIA* [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.