Hi all Having searched the available documentation on R, I request for help in sorting out the underlying problem. I have a huge dataset containing 2 variables x and y, which is a daily price series. I would like to observe the quarterly correlations among these two variables. Is there anyway where i can calculate cor.coeff by using a grouping variable in R. thanks in advance for the help rgds snvk
by(mydata, mydata$GROUPING, function(x) cor(x$x, x$y, use="pair")) ?by Krishna wrote:> Hi all > > Having searched the available documentation on R, I request for help > in sorting out the underlying problem. > > I have a huge dataset containing 2 variables x and y, which is a daily > price series. > > I would like to observe the quarterly correlations among these two > variables. Is there anyway where i can calculate cor.coeff by using a > grouping variable in R. > > thanks in advance for the help > > rgds > > snvk > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
Hi Mr. Cleland Could you please detail the function. Thanks and best regards snvk On 8/24/05, Chuck Cleland <ccleland at optonline.net> wrote:> by(mydata, mydata$GROUPING, function(x) cor(x$x, x$y, use="pair")) > > ?by > > Krishna wrote: > > Hi all > > > > Having searched the available documentation on R, I request for help > > in sorting out the underlying problem. > > > > I have a huge dataset containing 2 variables x and y, which is a daily > > price series. > > > > I would like to observe the quarterly correlations among these two > > variables. Is there anyway where i can calculate cor.coeff by using a > > grouping variable in R. > > > > thanks in advance for the help > > > > rgds > > > > snvk > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > > > -- > Chuck Cleland, Ph.D. > NDRI, Inc. > 71 West 23rd Street, 8th floor > New York, NY 10010 > tel: (212) 845-4495 (Tu, Th) > tel: (732) 452-1424 (M, W, F) > fax: (917) 438-0894 >
Hi Mr. Cleland it worked excellently well, and i believe the same logic or function by() can be used even for running regressions on subsets of huge datasets. correct me if iam wrong thank you for the help rgds snvk On 8/24/05, Krishna <snvk4u at gmail.com> wrote:> Hi Mr. Cleland > > Could you please detail the function. > > Thanks and best regards > > snvk > > On 8/24/05, Chuck Cleland <ccleland at optonline.net> wrote: > > by(mydata, mydata$GROUPING, function(x) cor(x$x, x$y, use="pair")) > > > > ?by > > > > Krishna wrote: > > > Hi all > > > > > > Having searched the available documentation on R, I request for help > > > in sorting out the underlying problem. > > > > > > I have a huge dataset containing 2 variables x and y, which is a daily > > > price series. > > > > > > I would like to observe the quarterly correlations among these two > > > variables. Is there anyway where i can calculate cor.coeff by using a > > > grouping variable in R. > > > > > > thanks in advance for the help > > > > > > rgds > > > > > > snvk > > > > > > ______________________________________________ > > > R-help at stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > > > > > > -- > > Chuck Cleland, Ph.D. > > NDRI, Inc. > > 71 West 23rd Street, 8th floor > > New York, NY 10010 > > tel: (212) 845-4495 (Tu, Th) > > tel: (732) 452-1424 (M, W, F) > > fax: (917) 438-0894 > > >
Krishna wrote:> Hi Mr. Cleland > > it worked excellently well, and i believe the same logic or function > by() can be used even for running regressions on subsets of huge > datasets. correct me if iam wrongYes. For example, the FUN argument to by() can be a summary of a linear model: by(warpbreaks, warpbreaks$tension, function(x) summary(lm(breaks ~ wool, data=x)))> thank you for the help > > rgds > > snvk > > On 8/24/05, Krishna <snvk4u at gmail.com> wrote: > >>Hi Mr. Cleland >> >>Could you please detail the function. >> >>Thanks and best regards >> >>snvk >> >>On 8/24/05, Chuck Cleland <ccleland at optonline.net> wrote: >> >>>by(mydata, mydata$GROUPING, function(x) cor(x$x, x$y, use="pair")) >>> >>>?by >>> >>>Krishna wrote: >>> >>>>Hi all >>>> >>>>Having searched the available documentation on R, I request for help >>>>in sorting out the underlying problem. >>>> >>>>I have a huge dataset containing 2 variables x and y, which is a daily >>>>price series. >>>> >>>>I would like to observe the quarterly correlations among these two >>>>variables. Is there anyway where i can calculate cor.coeff by using a >>>>grouping variable in R. >>>> >>>>thanks in advance for the help >>>> >>>>rgds >>>> >>>>snvk >>>> >>>>______________________________________________ >>>>R-help at stat.math.ethz.ch mailing list >>>>https://stat.ethz.ch/mailman/listinfo/r-help >>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >>>> >>> >>>-- >>>Chuck Cleland, Ph.D. >>>NDRI, Inc. >>>71 West 23rd Street, 8th floor >>>New York, NY 10010 >>>tel: (212) 845-4495 (Tu, Th) >>>tel: (732) 452-1424 (M, W, F) >>>fax: (917) 438-0894 >>> >> > >-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894