Hello list, I am making scatterplots of data that vary sinusoidally over 24 hours. With a bit of previous help from this list, I now can get an x-axis with time tics from 00:00 on the left edge to 12:00 in the middle and 00:00 on the right edge, i.e., just 24 hours. Now I would like to fit a sin function to the plot. I've looked all over CRAN and the web in general, but have not found a method or package for this. Can anyone make a suggestion? Thanks, =Randy Using R 2.4.0 on Solaris (unix). R. Zelick email: zelickr at pdx.edu Department of Biology voice: 503-725-3086 Portland State University fax: 503-725-3888 mailing: P.O. Box 751 Portland, OR 97207 shipping: 1719 SW 10th Ave, Room 246 Portland, OR 97201
Read up on the discrete Fourier transform: http://en.wikipedia.org/wiki/Discrete_Fourier_transform http://en.wikipedia.org/wiki/Frequency_spectrum#Spectrum_analysis> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Randy Zelick > Sent: Tuesday, December 19, 2006 2:52 PM > To: R list server posting > Subject: [R] fit sine? > > Hello list, > > I am making scatterplots of data that vary sinusoidally over > 24 hours. > With a bit of previous help from this list, I now can get an > x-axis with > time tics from 00:00 on the left edge to 12:00 in the middle > and 00:00 on > the right edge, i.e., just 24 hours. > > Now I would like to fit a sin function to the plot. I've > looked all over > CRAN and the web in general, but have not found a method or > package for > this. > > Can anyone make a suggestion? > > Thanks, > > =Randy> > > Using R 2.4.0 on Solaris (unix). > > > R. Zelick email: zelickr at pdx.edu > Department of Biology voice: 503-725-3086 > Portland State University fax: 503-725-3888 > > mailing: > P.O. Box 751 > Portland, OR 97207 > > shipping: > 1719 SW 10th Ave, Room 246 > Portland, OR 97201 > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. >
Look at the functions: nls, optimize, optim. Also look at the packages circular and CircStats. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111 -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Randy Zelick Sent: Tuesday, December 19, 2006 12:52 PM To: R list server posting Subject: [R] fit sine? Hello list, I am making scatterplots of data that vary sinusoidally over 24 hours. With a bit of previous help from this list, I now can get an x-axis with time tics from 00:00 on the left edge to 12:00 in the middle and 00:00 on the right edge, i.e., just 24 hours. Now I would like to fit a sin function to the plot. I've looked all over CRAN and the web in general, but have not found a method or package for this. Can anyone make a suggestion? Thanks, =Randy Using R 2.4.0 on Solaris (unix). R. Zelick email: zelickr at pdx.edu Department of Biology voice: 503-725-3086 Portland State University fax: 503-725-3888 mailing: P.O. Box 751 Portland, OR 97207 shipping: 1719 SW 10th Ave, Room 246 Portland, OR 97201 ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.