# [R] Sin curve question

Eric Berger er|cjberger @end|ng |rom gm@||@com
Sat Jul 24 21:04:09 CEST 2021

```Alternatively with base graphics

N <- 500 ## number of points (arbitrary)
degrees <- seq(from=0,to=180,length=N)
degreesToRadians <- function(d) { pi * d / 180.0}  ## vectorIzed!
xlab="x",ylab="sin(x)",main="sin(x) vs x\nx is in degrees")

On Sat, Jul 24, 2021 at 9:52 PM Sorkin, John <jsorkin using som.umaryland.edu>
wrote:

> Try something like the following
>
> copdat\$degrees <- c(1:180)
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street<x-apple-data-detectors://12>
> GRECC<x-apple-data-detectors://12> (BT/18/GR)
> Baltimore, MD 21201-1524<x-apple-data-detectors://13/0>
> (Phone) 410-605-711<tel:410-605-7119>9
> (Fax) 410-605-7913<tel:410-605-7913> (Please call phone number above prior
> to faxing)
>
> On Jul 24, 2021, at 2:41 PM, Thomas Subia via R-help <r-help using r-project.org>
> wrote:
>
> ﻿Colleagues,
>
> Here is my code which plots sin(x) vs x, for angles between 0 and 180
> degrees.
>
> library(ggplot2)
> library(REdaS)
> copdat\$degrees <- c(0,45,90,135,180)
>
> ggplot(copdat,aes(x=degrees,y=sin_x))+
>  geom_point(size = 2)+ geom_line()+
>  theme_cowplot()+xlab("x")+
>  ylab("sin(x)")+
>  scale_x_continuous(breaks=seq(0,180,30))+
>  ggtitle("sin(x) vs x\nx is in degrees")
>
> My trig students would prefer a curved line plot similar to what can be
> plotted with Excel smooth line functionality.
> I wanted to provide a relatively simple R script using ggplot to do this
> without having to resort to fitting a sine curve to these points.
>
> Some guidance would be appreciated.
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>
> and provide commented, minimal, self-contained, reproducible code.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help